【发布时间】:2017-10-27 17:31:23
【问题描述】:
我正在使用带有 Angular、Typescript 和 d3.js(除其他外)的 Node.js 设计一个 Web 应用程序。该应用程序已启动并运行,库功能按预期工作。但是,我无法正确编译我的 Typescript 文件,因为我遇到了 d3 的类型定义错误(见下文)。
Error:(182, 27) TS2339:Property 'time' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(187, 27) TS2339:Property 'scale' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(193, 28) TS2339:Property 'svg' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(195, 47) TS2339:Property 'time' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(258, 28) TS2339:Property 'svg' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(915, 23) TS2339:Property 'svg' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(970, 25) TS2339:Property 'svg' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(1147, 21) TS2339:Property 'svg' does not exist on type 'typeof
"C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
这些属性似乎工作正常,但 typescript 编译器无法识别它们,这表明我的 @types/d3 依赖项有问题。
我使用的d3.js版本是3.4.8,@types/d3的版本是4.3.0。
我确定这两个版本不匹配,但我仍然需要找到一对匹配的版本号,并提供 Typescript 无法识别的属性。
鉴于我需要访问的属性,任何人都可以推荐这些库的组合吗?我假设我对 d3 的打字在某种程度上落后了,所以也许旧版本会合适?如果有人有答案,甚至有系统的方法来找出我需要什么版本,那将非常有帮助。
【问题讨论】:
标签: javascript typescript d3.js compilation typescript-typings