Why Does This Typescript Output “[Class] is not a constructor.”?

后端 未结 12 1264
清歌不尽
清歌不尽 2021-01-17 07:55

I\'m working in typescript 1.5 in visual studio. I have a main class called app.ts, and another called FizzBuzzManager.ts. I can\'t figure out what is wrong with this code,

12条回答
  •  醉话见心
    2021-01-17 08:42

    I had this error my_imported_module_1.MyModule is not a constructor.

    I was using the approach when I got this error: import { MyModule } from 'my-module-sdk';

    but I got it to work when I changed it to this approach: const MyModule = require('my-module-sdk');

    In my tsconfig.json, I have "target" set to "es5", and tried changing it "es6" and that still didn't help.

    Here are some of my other tsconfig options:

    "target": "es5",
    "module": "esnext",
    "declaration": true,
    "rootDir": "./src",
    "moduleResolution": "node",
    "lib": ["es6", "dom", "es2016", "es2017", "es2018", "es2019", 
    "es2020"],
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": false
    

提交回复
热议问题