1.0.0 • Published 10 months ago

@mt-kit/ts-config v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

@mt-kit/ts-config

1、安装

npm install typescript @mt-kit/ts-config --save-dev

2、使用

# 初始化
npx tsc --init

3、各个属性的作用

基础配置 (base.json)

属性名作用
target编译目标
module编译模块
moduleResolution模块解析策略
strict启用所有严格类型检查选项
declaration生成对应的.d.ts声明文件
noImplicitOverride禁止隐式覆盖父类方法
noUnusedLocals检查未使用的局部变量
esModuleInterop启用ES模块互操作性
useUnknownInCatchVariables将catch变量设为unknown类型
composite启用项目编译
declarationMap生成声明文件的sourcemap
inlineSources将源文件嵌入sourcemap中
isolatedModules将每个文件作为独立模块编译
skipLibCheck跳过声明文件的类型检查
noUnusedParameters检查未使用的函数参数
preserveWatchOutput保留watch模式的控制台输出
resolveJsonModule允许导入JSON模块
removeComments移除注释
baseUrl模块解析的基准路径
noImplicitThis禁止隐式any类型的this
verbatimModuleSyntax使用字面模块语法
useDefineForClassFields使用define语义定义类字段
lib包含的库文件
outDir输出目录
sourceMap生成sourcemap文件
allowJs允许编译JavaScript文件
forceConsistentCasingInFileNames强制文件名大小写一致
allowSyntheticDefaultImports允许合成默认导入
strictFunctionTypes启用函数参数严格类型检查
noImplicitAny禁止隐式any类型
paths模块路径映射配置
types包含的类型声明文件
emitDeclarationOnly仅生成声明文件
files包含的特定文件列表
include包含的文件模式
newLine指定换行符格式
noErrorTruncation禁止截断错误信息
preserveConstEnums保留const枚举
stripInternal移除带有@internal标记的代码

Vue 配置 (vue.json)

属性名作用
jsxJSX代码生成方式
jsxImportSourceJSX导入源
experimentalDecorators启用实验性装饰器支持

React 配置 (react.json)

属性名作用
noEmit禁止生成输出文件
incremental启用增量编译
plugins使用TypeScript插件

Node 配置 (node.json)

属性名作用
lib仅包含ESNext库
noEmit禁止生成输出文件

4、不同环境的配置

  • React: 使用 @mt-kit/ts-config/react
  • Vue: 使用 @mt-kit/ts-config/vue
  • Node: 使用 @mt-kit/ts-config/node

5、版本要求

  • TypeScript >= 5.0.0
1.0.0

10 months ago