zoukankan      html  css  js  c++  java
  • TypeScript 常见错误与解决方案

    1、TS1005、TS2004

    ERROR in [at-loader] ./node_modules/@types/d3-dsv/index.d.ts:493:52
    
      TS1005: ',' expected.
    
    ERROR in [at-loader] ./node_modules/@types/d3-dsv/index.d.ts:159:51
    
      TS2304: Cannot find name 'readonly'.

     问题原因:
      typescript版本太低,需要升级到最新版本

     解决方案:

      报错时的版本是3.3.3,升级到4.2.3后,报错消失

    2、TS2308

    ERROR in [ at-loader ] ./node_modules@types/d3/index.d.ts:26:1

      TS2308: Module 'd3-array' has already exported a member named 'map' .  Consider explicitly re-exporting to resolve the ambiguity.

    ERROR in [ at-loader ] ./node_modules@types/d3/index.d.ts:26:1
    
      TS2308: Module 'd3-array' has already exported a member named 'map' .  Consider explicitly re-exporting to resolve the ambiguity.

    问题原因:

      两个文件都导出了同一个名为map的方法,所以ts检测报错

    解决方案:

      项目的tsconfig.json中,配置编译选项,skipLibCheck设为true。忽略所有的声明文件( *.d.ts)的类型检查。

    3、TS2339

    ERROR in [ at-loader ] ./src/wave-artboard/wave-artboard.tsx:233:12

      TS2339: Property 'event' does not exist on type 'typeof import("F:/eFlowerProject.BSR-H5/node_modules/@types/d3/index")'.

    ERROR in [ at-loader ] ./src/wave-artboard/wave-artboard.tsx:233:12
    
      TS2339: Property 'event' does not exist on type 'typeof import("F:/eFlowerProject.BSR-H5/node_modules/@types/d3/index")'.

    问题原因:

      项目中使用d3.event从而报错

    解决方案:

      将d3.event 改成 d3[event]

    跳转typescript官方文档请点这https://www.tslang.cn/docs/handbook/nightly-builds.html

  • 相关阅读:
    [考试]20151017数据结构
    [考试]20151016动态规划
    [考试]20151015分治
    [BZOJ1501/NOI2005]智慧珠游戏
    [BZOJ3139/HNOI2013]比赛
    [考试]20151013搜索
    BZOJ3082: Graph2
    BZOJ4690: Never Wait for Weights
    BZOJ4668: 冷战
    BZOJ3262: 陌上花开
  • 原文地址:https://www.cnblogs.com/liuxuande/p/14634521.html
Copyright © 2011-2022 走看看