VS
Code was designed to be the perfect TypeScript editor.
如果你用其他编辑器,我们可以全局安装TypeScript command-line tool
npm install -g typescript
# 或者
yarn global add typescript
进入项目文件夹,执行命令
tsc --init
则会创建tsconfig.json文件
{
"compilerOptions": {
"target": "ES2020",
"module": "es2020",
"allowJs": true,
"checkJs": true,
"typeRoots": [
"@types",
"node_modules/@types"
],
"esModuleInterop": true,
}
}
执行下列命令进行类型检查,且不产生输出文件
tsc --noEmit