我可以使用最新的稳定TypeScript还是应该坚持使用AngularCLI随附的版本? [英] Can I use latest stable TypeScript or should I stick with the version shipped with AngularCLI?
问题描述
我找不到关于是否使用可用的最新稳定版本升级TypeScript版本的任何官方建议.
I wasn't able to find any official recommendation about whether or not upgrade the TypeScript version using the latest stable version available.
在创建新项目时,AngularCLI会在package.json
中自动设置npm版本.当前是:
The npm version is automatically set in package.json
by AngularCLI when creating a new project. It currently is:
"typescript": "~2.4.2"
表示最新的2.4.x
版本.我想知道是否有可能使用最新的稳定TypeScript版本(及其含义),例如2.5.x
.
which means latest 2.4.x
version. I was wondering if it would be possible to use the latest stable TypeScript version (and what would be the implications), for example 2.5.x
.
是否存在设置~2.4.2
而不是"^2.4.2
(这意味着最新的2.x.x
版本)的特定原因.
Is there a specific reason for setting ~2.4.2
and not "^2.4.2
(which means latest 2.x.x
version).
推荐答案
Angular cli可能并不总是支持最新版本的TypeScript.
存在一些与PR有关的问题:
-支持TypeScript 2.4+
- Typescript 2.4支持
- feat(@ angular/cli):支持TypeScript 2.4
Angular cli may not always support the latest version of TypeScript.
There is some issues and PR's related to that:
- Support TypeScript 2.4+
- Typescript 2.4 support
- feat(@angular/cli): support TypeScript 2.4
也请记住,最新的TypeScript版本可能与您的Angular版本不兼容.
Also bare in mind that the latest TypeScript version might not be compatible with your Angular version.
如果您想跳转到新的/最新的TypeScript版本,后果自负.一旦这样做,您必须确保它不会破坏测试(ng t
),产品构建(ng build --prod
)等之类的东西.
If you want to jump to a new/latest TypeScript version - it is at your own risk. Once you do so you have to make sure that it is not breaks anything like tests(ng t
), prod build(ng build --prod
), etc.
如果您坚持使用默认的cli TypeScript版本,那么-安全.
If you stick to the default cli TypeScript version you - are safe.
更新2017年9月9日:对于那些关心使用cli和最新TypeScript进行结帐的用户,此注释,因为最新的cli 1.4
中引入了TypeScript version warning logic
. 这是什么基于(cli团队推荐):
UPDATE 09 Sept 2017: For anyone who care about using the cli with the latest TypeScript checkout this recent github issue and this particular comment as there was a TypeScript version warning logic
introduced in the latest cli 1.4
. Here is what it is based on(angular cli team recommendation):
const versionCombos = [
{ compiler: '>=2.3.1 <3.0.0', typescript: '>=2.0.2 <2.3.0' },
{ compiler: '>=4.0.0 <5.0.0', typescript: '>=2.1.0 <2.4.0' },
{ compiler: '>=5.0.0 <6.0.0', typescript: '>=2.4.0 <2.6.0' }
];
这篇关于我可以使用最新的稳定TypeScript还是应该坚持使用AngularCLI随附的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!