From bf30cbfb85e49f95f45e3d3c5c65d0d7bd318ba0 Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Sun, 15 Nov 2020 10:48:31 +0100 Subject: [PATCH] - Fixed #389 --- README.md | 10 ++++++++++ src/templates/core/node/request.hbs | 2 +- test/e2e/scripts/compileWithTypescript.js | 10 ++++++++++ tsconfig.json | 3 ++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8ea98f92..e4551089 100644 --- a/README.md +++ b/README.md @@ -441,6 +441,16 @@ npm install node-fetch --save-dev npm install form-data --save-dev ``` +In order to compile the project and resolve the imports, you will need to enable the `allowSyntheticDefaultImports` +in your `tsconfig.json` file. + +```json +{ + "allowSyntheticDefaultImports": true +} +``` + + [npm-url]: https://npmjs.org/package/openapi-typescript-codegen [npm-image]: https://img.shields.io/npm/v/openapi-typescript-codegen.svg [license-url]: LICENSE diff --git a/src/templates/core/node/request.hbs b/src/templates/core/node/request.hbs index 8d916521..ee5e3338 100644 --- a/src/templates/core/node/request.hbs +++ b/src/templates/core/node/request.hbs @@ -1,6 +1,6 @@ {{>header}} -import * as FormData from 'form-data'; +import FormData from 'form-data'; import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch'; import { types } from 'util'; diff --git a/test/e2e/scripts/compileWithTypescript.js b/test/e2e/scripts/compileWithTypescript.js index 0987ad71..8c9969cc 100644 --- a/test/e2e/scripts/compileWithTypescript.js +++ b/test/e2e/scripts/compileWithTypescript.js @@ -12,6 +12,16 @@ function compileWithTypescript(dir) { module: 'es6', moduleResolution: 'node', lib: ['es6', 'es2017', 'dom'], + declaration: false, + declarationMap: false, + sourceMap: false, + noImplicitReturns: true, + noImplicitThis: true, + noImplicitAny: true, + strict: true, + strictNullChecks: true, + strictFunctionTypes: true, + allowSyntheticDefaultImports: true, }, include: ['./index.ts'], }; diff --git a/tsconfig.json b/tsconfig.json index a3bb634d..f5e80d1d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,8 @@ "noImplicitAny": true, "strict": true, "strictNullChecks": true, - "strictFunctionTypes": true + "strictFunctionTypes": true, + "allowSyntheticDefaultImports": true }, "files": [