• This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.


      This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

    对引用的方式进行修改

    import md5 from "md5"   ==> import * as md5 from "md5"

    在测试TypeScript时,使用package.json 中的script 命令时,不能使用

    import md5 from "md5"

    而在添加了tsconfig.json 

    {

       "compilerOptions": {
       
        "target": "es6",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
       
        "module": "es6",                                /* Specify what module code is generated. */
     
        "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
     
        "forceConsistentCasingInFileNames": true,            /* Ensure that casing is correct in imports. */
       
        "strict": true,                                      /* Enable all strict type-checking options. */
       
        "skipLibCheck": true,                                 /* Skip type checking all .d.ts files. */
     
        "outDir": "./dist"
      }

    }

    使用tsc进行build 时,又可以使用 import md5 from "md5",但是不能使用 import * from as md5 from "md5"

  • 相关阅读:
    Haproxy 【转载】
    Nginx介绍
    Day 13 进程和线程
    运维第一课
    面试bb
    Day 12 字符串和正则表达式
    Day 11 文件和异常
    Day10 图形用户界面和游戏开发
    Day9 面向对象进阶
    day8 面向对象编程基础
  • 原文地址:https://www.cnblogs.com/googlegis/p/16458263.html
Copyright © 2020-2023  润新知