Javascript d3.js类型脚本依赖项编译错误

Javascript d3.js类型脚本依赖项编译错误,javascript,typescript,d3.js,compilation,typescript-typings,Javascript,Typescript,D3.js,Compilation,Typescript Typings,我正在设计一个web应用程序,使用Node.js和Angular、Typescript和d3.js(以及其他内容)。应用程序已启动并运行,库功能按预期工作。然而,我无法正确编译我的Typescript文件,因为我在d3的类型定义中遇到了错误(见下文) 这些属性似乎工作正常,但typescript编译器无法识别它们,这表明我的@types/d3依赖项有问题 我使用的d3.js版本是3.4.8,而@types/d3的版本是4.3.0 我确信这两个版本不匹配,但我仍然需要找到一对匹配的版本号,并提供T

我正在设计一个web应用程序,使用Node.js和Angular、Typescript和d3.js(以及其他内容)。应用程序已启动并运行,库功能按预期工作。然而,我无法正确编译我的Typescript文件,因为我在d3的类型定义中遇到了错误(见下文)

这些属性似乎工作正常,但typescript编译器无法识别它们,这表明我的@types/d3依赖项有问题

我使用的d3.js版本是3.4.8,而@types/d3的版本是4.3.0

我确信这两个版本不匹配,但我仍然需要找到一对匹配的版本号,并提供Typescript无法识别的属性


有人能为这些库推荐一个组合,在我需要访问的属性下可以工作吗?我假设我的d3打字在某种程度上落后了,所以也许旧版本会合适?如果有人有答案,甚至有系统的方法来找出我需要的版本,那将是非常有帮助的。

我知道这个问题几个月前已经发布了,但仍然需要回答

首先检查package.json文件中的d3和@types版本。 正如你所说

  • 您使用的是D3V3.4.8,因此应该使用@types/d3@3.4.8.
  • 您正在使用@types/4.3.0,它将与d3 v4.3.0兼容
注意:始终使用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"'.