1.配置 windows10+vscode+npm+typescript :
- 1.安装全局npm
- >npm install typescript -g
-
-
- 2.初始化npm配置
- >tsc --init
-
-
- 3.把.ts编译成.js (注意:找对代编译文件的位置如.\src\ts\**.ts)
- >tsc **.ts
> tsc TypeScript Compile windows下这句可以不用,用tsc --init 初始化,否则报如下错误:
error TS6231: Could not resolve the path 'Compile' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
The file is in the program because:
Root file specified for compilation
d.ts', '.cts', '.d.cts', '.mts', '.d.mts'.
The file is in the program because:
Root file specified for compilation
2.使用:
- 1.自动监听**.ts文件,自动编译成**.js(注意:修改.ts文件后保存.ts文件才会自动编译)
- >tsc **.ts -watch