简体   繁体   English

打字稿类型定义版本

[英]Typescript type definitions versions

I'm having issues with type definitions (td) versioning. 我在类型定义(td)版本控制方面遇到问题。 Could someone explain to me why the current guidelines enforce the use of a version for type definitions for all versions but the latest one and why they don't say anything about specifying a version for type definitions they depend upon? 有人可以向我解释为什么当前的指南对所有版本(但最新的版本)都强制使用一个版本作为类型定义,以及为什么他们不对指定其依赖的类型定义使用任何版本?

I'll explain my perplexity: I'm facing the issue that right now, the browserify td doesn't work with the latest node td (but it works with v0.11.0). 我将解释我的困惑:我现在面临的问题是, browserify td不适用于最新的node td(但适用于v0.11.0)。 Given the current guidelines, how can someone who writes a td that references another one be sure that a new update to the referenced td doesn't brake theirs? 根据当前的指导原则,编写引用另一个td的td的人如何确保对引用的td的新更新不会阻止他们的工作? I don't see a way right now. 我现在没有办法。 As an end user, right now the only solution I've got is to manually change the browserify td to reference the node version that doesn't break it. 作为最终用户,现在我唯一的解决方案是手动更改browserify td以引用不会破坏它的node版本。 It doesn't sound like an ideal scenario to me. 对我来说,这听起来并不理想。

There are two interesting sides to this discussion. 该讨论有两个有趣的方面。

The first problem is that the definitions get updated as new versions of the TypeScript language come out with features that make definitions easier and more accurate. 第一个问题是,随着TypeScript语言新版本的发布,这些定义具有更新的功能,这些功能使定义更容易,更准确。 A good example of this is union types. 联合类型就是一个很好的例子。

The second problem is that the third party libraries are constantly being updated and the definitions therefore move with the libraries. 第二个问题是第三方库不断更新,因此定义随库一起移动。

If you are using "pretty much the latest of everything" this is all fine, but if you are looking for a combination it will become impossible (ie TypeScript 1.1 with jQuery 1.9). 如果您使用的是“几乎所有产品中的最新产品”,那都很好,但是如果您正在寻找一种组合,则将不可能(例如TypeScript 1.1和jQuery 1.9)。

You can usually see the history of a definition by reviewing the changes, so if you need an older version of a library you can find it - but you may stumble across the TypeScript language issue. 通常,您可以通过查看更改来查看定义的历史记录,因此,如果需要旧版本的库,可以找到它-但是您可能会偶然发现TypeScript语言问题。 For example, if you wanted to use a rather old version of a library, you might find the .d.ts uses bool not boolean and needs to be updated before it will compile. 例如,如果您想使用旧版本的库,则可能会发现.d.ts使用的bool不是boolean并且需要先进行更新才能编译。

There are two related issues on Definitely Typed relating to this: 与“绝对类型”相关的两个相关问题是:

https://github.com/borisyankov/DefinitelyTyped/issues/3031 https://github.com/borisyankov/DefinitelyTyped/issues/3031

https://github.com/borisyankov/DefinitelyTyped/issues/2972 https://github.com/borisyankov/DefinitelyTyped/issues/2972

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM