What does “… resolves to a non-module entity and cannot be imported using this construct” mean?

后端 未结 4 682
忘掉有多难
忘掉有多难 2020-11-28 04:05

I have some TypeScript files:

MyClass.ts

class MyClass {
  constructor() {
  }
}
export = MyClass;

MyFunc.ts

4条回答
  •  孤独总比滥情好
    2020-11-28 04:18

    I got this error when trying to include a npm debounce package in my project.

    When I tried the accepted solution above I got an exception:

    Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.

    This ended up working:

    import debounce from 'debounce' 
    

提交回复
热议问题