Typescript中关联软件包的版本相关联

Typescript中关联软件包的版本相关联

本文介绍了如何将@types版本与NodeJS Typescript中关联软件包的版本相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有节点6.3.1的打字稿2.2的nodejs项目进行工作,我想从使用类型迁移到使用@types.通过这样做,我遇到了一系列问题,这些问题与@types文件的版本和相应的npm软件包之间是否存在关联.

I am working on a nodejs project with typescript 2.2 that is using node 6.3.1 and I want to migrate from using typings to using @types. By doing so I ran into a set of questions related to whether there is a relationship between the version of the @types file and the corresponding npm package.

如果以茉莉花为例,则类型定义的现有版本为

If I use jasmine as an example, the existing versions of the types definitions are

npm show @types/jasmine@* 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'

但是,如果我检查一下我所拥有的茉莉花包装的版本;

But if I examine the versions of the jasmine packages I have;

npm show jasmine@* 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匹配.

Let’s say I am using version 2.4.0 of jasmine, which version of @types/jasmine should I pick? Because even if I use the latest of both, 2.5.46 does not match with 2.5.3.

另一个例子是节点本身,@ types中基本上有6.0或7.0版本,而键入仅显示以下内容,报告为过时的为6.0.那么,这些类型实际上绑定到哪个版本的节点?

Another example would be node itself, there are basically 6.0 or 7.0 versions in @types, and typings has only the ones shown below, being 6.0 reported as obsolete. So, what version of node are those typings actually tied to?

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

谢谢

推荐答案

DefinitelyTyped软件包的主要版本和次要版本应该与它们所针对的软件包的主要版本和次要版本相对应.每当.d.ts文件由于其他原因而更改时,补丁程序版本就会增加.由于次要版本不应表示重大更改,因此从理论上讲,您可以使用2.a.b.c库可用的最高2.x.y定义文件.

The major and minor versions of the DefinitelyTyped packages are supposed to correspond to the major and minor versions of the package they are types for. The patch version increments whenever the .d.ts file changes for other reasons. Because the minor version shouldn't represent breaking changes, in theory, you can use the highest 2.x.y definition file available for a 2.a.b.c library.

但是现在开始警告了.

  • 定义文件中的标题可能未在正确的时间更改
  • 图书馆作者不一定遵循semver *
  • 该定义文件在任何给定点都可能在任一方向上都不是100%正确的(即在2.5版本下列出2.6功能,或者在2.5文件中未列出功能2.4)

*实际上,没有人这样做

* In fact, no one does

这篇关于如何将@types版本与NodeJS Typescript中关联软件包的版本相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 14:19