基本使用
编译选项
-
单个文件: tsc 名称 -w
-
多个文件
- 创建tsconfig.json文件
- tsc -w
-
tsconfig.json 文件的配置
// 用来指定哪些文件需要被编译 // /**表示任意目录 *表示任意文件 "include":[ "./src/**/*" ], //不需要被编译的目录 //默认值 ["node_modules","bower_components","jspm_packages"] "exclude":[ "./src/hellow/**/*" ], //定义被继承的配置文件 "extends":"./", //置顶被编译文件的列表,只有需要编译的文件 "files":[ "文件名1", "文件名2" ], //编译器的选项 "compilerOptions":{ //target 用于指定编译后的ES版本(默认为ES3) "target":"ES6",//es5\es6\esnext... //module 指定要使用的模块化方案 "module":"es6",//commonjs\amd\... //lib 用来指定项目中要使用的库(基本不用改) "lib":["dom"],//es5\es6\dom... //outDir 指定编译后文件所在的目录 "outDir":"./dist", //outFile 将代码合并为一个文件 //设置outFile后,所有的全局作用域中的代码会合并到同一个文件中 "outFile":"./dist/app.js", //allowJs 是否对js文件进行编译,默认为false "allowJs":false, //chackJs 是否检查js代码是否符合语法规范,默认为false "chackJs":false, //removeComments 是否移除注释 "removeComments":true, //noEmit 不生成编译后的文件 "noEmit":false, //noEmitOnError 有错误时不生成js文件 "noEmitOnError":true, //alwaysStrict 用于设置编译后的问价是否使用严格模式,默认false "alwaysStrict":true, //noImplicitAny 不允许隐式的any类型 "noImplicitAny":true, //noImplicitThis 不允许不明确类型的this "noImplicitThis":true, //strict 严格检查的总开关 "strict":true, //strictNullChecks 严格的检查空值 "strictNullChecks":true, }
- Nuxt ts 检测
npx nuxi typecheck
- Nuxt ts 检测