更新 Angular2 项目中的 Typescript
Update Typescript in Angular2 project
我在 Visual Studio 中有一个使用 Typescript 的 Angular2 项目。我想将 Typescript 从 1.8 更新到 2.0.x。在我的系统中,我更新了打字稿和 tsc -v
日志 Version 2.0.10
package.json,除其他外,包含
"devDependencies": {
....
"typescript": "^1.8.10",
"typings": "^1.3.1",
...
}
为了更新打字稿,在package.json中把版本改成"typescript": "^2.0.10"
就够了吗?另外,typescript 和 typings 版本的关系是什么,当涉及到更新时?
更新 package.json 和 运行 npm install
中的打字稿版本就足以升级您的项目使用的版本。
Typescript 2.x 引入了一种管理类型的新方法,使用 @types/... 限定符 npm 包 - 您仍然可以使用之前使用过的类型 - 但您可能希望将其更新为在撰写此答案时来自 npm 的最新版本为 2.0.0
如果您有兴趣,这里有更多关于新@types 的信息和讨论https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/
对于精确版本
- npm install typescript@2.0.10 --save-dev
最新版本
- npm install typescript@latest --save-dev
我在 Visual Studio 中有一个使用 Typescript 的 Angular2 项目。我想将 Typescript 从 1.8 更新到 2.0.x。在我的系统中,我更新了打字稿和 tsc -v
日志 Version 2.0.10
package.json,除其他外,包含
"devDependencies": {
....
"typescript": "^1.8.10",
"typings": "^1.3.1",
...
}
为了更新打字稿,在package.json中把版本改成"typescript": "^2.0.10"
就够了吗?另外,typescript 和 typings 版本的关系是什么,当涉及到更新时?
更新 package.json 和 运行 npm install
中的打字稿版本就足以升级您的项目使用的版本。
Typescript 2.x 引入了一种管理类型的新方法,使用 @types/... 限定符 npm 包 - 您仍然可以使用之前使用过的类型 - 但您可能希望将其更新为在撰写此答案时来自 npm 的最新版本为 2.0.0
如果您有兴趣,这里有更多关于新@types 的信息和讨论https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/
对于精确版本
- npm install typescript@2.0.10 --save-dev
最新版本
- npm install typescript@latest --save-dev