Importing Victor.js in TypeScript?

前端 未结 3 2037
感情败类
感情败类 2021-02-03 20:26

I\'m trying to use the victor.js library in a TypeScript project (3.0.1) and I\'m having real heartache trying to import and use it. I\'ve installed it from npm along with it\'s

3条回答
  •  抹茶落季
    2021-02-03 20:52

    I see there has already been excellent answers but would like to add this shorter answer.

    Error message: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.ts(2497)

    I had this problem with importing when moving from es5 to es6 (and javascript to typescript) when converting my own javascript file to typescript.

    Importing like import * as File from "./MyFile" in OtherFile.ts .

    In MyFile.ts file I had export = {funcName} at the end.

    The solution was to remove = like this export {funcName} from the MyFile.ts file.

    (Hope this helps someone, first time trying to make an answer for a an error/problem)

提交回复
热议问题