Visual Studio Code包含TypeScript语言支持,但不包括TypeScript编译器tsc。您需要在全局或工作区中安装TypeScript编译器,以将TypeScript源代码转换为JavaScript(tsc HelloWorld.ts)。
安装TypeScript的最简单方法是通过npm,即Node.js包管理器,-g
表示全局安装。
npm install -g typescript
tsc --version
xm@xm-Vostro-3670:~/project$ tsc --version Version 3.3.3333
HelloWorld
文件夹和hello_world.ts
文件mkdir HelloWorld
const text:string = 'hello world';console.log(text);
{ "compilerOptions": { "target": "es5", "module": "commonjs", "outDir": "out", "sourceMap": true } }
tsc:build-tsconfig.json
F5
发现目录下多了一个out
文件夹配置的是"outDir": "out"
,DEBUG CONSOLE
输出hello world
。
text
保存按下F5
更多编程相关知识,请访问:编程视频!!
以上就是VSCode中配置TypeScript自动编译的详细内容,更多请关注群英网络其它相关文章!
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2018 群英 版权所有 茂名市群英网络有限公司
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号-36 粤公网安备 44090202000006号 粤工商备P091701000595