# Typescript (opens new window)
# 安装 TypeScript
npm i -g typescript
# 检查版本
tsc -v
# 查看命令
tsc --help
# 生成 tsconfig.json
tsc --init
# 在项目使用 typescript
- 如果使用的是 cli 构建的项目可以直接使用 cli 命令
vue add typescript
- 使用 webpack 搭建的项目
module.exports = {
// ...
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exculde: '/node_modules/'
}
]
}
// ...
}
类型 →