2017-03-28 47 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