2017-03-28 65 views
5

我正在使用节点6.3.1的打印机typecript 2.2的nodejs项目上工作,并且我想从使用类型转换为使用@types。通过这样做,我遇到了一系列与@types文件的版本和相应的npm包之间是否存在关系有关的问题。如何将@types的版本与NodeJS Typescript中关联包的版本相关联?

如果我使用茉莉花为例,该类型定义的现有版本

npm show @types/[email protected]* version 
@types/[email protected] '1.3.0' 
@types/[email protected] '1.3.1' 
@types/[email protected] '1.3.2' 
@types/[email protected] '2.2.29' 
@types/[email protected] '2.2.30' 
@types/[email protected] '2.2.31' 
@types/[email protected] '2.2.32' 
@types/[email protected] '2.2.33' 
@types/[email protected] '2.2.34' 
@types/[email protected] '2.5.35' 
@types/[email protected] '2.5.36' 
@types/[email protected] '2.5.37' 
@types/[email protected] '2.5.38' 
@types/[email protected] '2.5.39' 
@types/[email protected] '2.5.40' 
@types/[email protected] '2.5.41' 
@types/[email protected] '2.5.42' 
@types/[email protected] '2.5.43' 
@types/[email protected] '2.5.44' 
@types/[email protected] '2.5.45' 
@types/[email protected] '2.5.46' 

但是如果我检查茉莉花包我的版本;

npm show [email protected]* version 
[email protected] '2.0.1' 
[email protected] '2.1.0' 
[email protected] '2.1.1' 
[email protected] '2.2.0' 
[email protected] '2.2.1' 
[email protected] '2.3.0' 
[email protected] '2.3.1' 
[email protected] '2.3.2' 
[email protected] '2.4.0' 
[email protected] '2.4.1' 
[email protected] '2.5.0' 
[email protected] '2.5.1' 
[email protected] '2.5.2' 
[email protected] '2.5.3' 

假设我正在使用茉莉花版本2.4.0,我应该选择哪种版本的@ types/jasmine?因为即使我使用两者的最新版本,2.5.46也不符合2.5.3。

另一个例子是节点本身,@types基本上有6.0或7.0版本,类型只有下面显示的那些,被报告为过时的6.0。那么,这些类型实际上与哪个版本的节点相关联呢?

typings view dt~node --versions 
TAG     VERSION DESCRIPTION COMPILER LOCATION 
          UPDATED 
7.0.0+20170322231424 7.0.0      github:DefinitelyTyped/DefinitelyTyped/node/index.d.ts#a4a912a0cd1849fa7df0e5d909c8625fba04e49d 2017-03-22T23:14:24.000Z 
6.0.0+20161121110008 6.0.0      github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#fb7fbd28b477f5e239467e69397ed020d92817e7 2016-11-21T11:00:08.000Z 

感谢

回答

1

的DefinitelyTyped包的主要和次要版本都应该对应于包装它们类型的主要和次要版本。每当.d.ts文件因其他原因而更改时,修补程序版本都会增加。由于次要版本不应代表重大更改,因此理论上可以使用可用于2.a.b.c库的最高2.x.y定义文件。

但现在警告开始了。

  • 定义文件头可能无法在正确的时间已经改变
  • 库作者并不一定遵循semver *
  • 定义文件可能不会在任何给定的点100%正确的,在任方向(即下一个版本2.5列出了2.6功能,或不列出2.4功能在2.5文件)

*事实上,没人能

+0

瑞恩在哪里你的知识来自哪里?你能否提供链接阅读?我努力匹配一些图书馆和他们的@类型。这似乎是一个大问题对我来说.. – Marecky

+1

我的知识来自我设计和实现@types –

+0

大声笑:)好吧,有没有任何地图@类型用于例如jQuery 1.4的版本?有任何图书馆/框架的指南吗?我正在寻找AngularJS @类型特定版本,它完全反映了我正在使用的角度版本。与ui路由器(angular-ui-router)相同 – Marecky