@ cffnpwr/ tsconfig
Cffnpwr 的共享类型脚本基础配置 .
配置
| 文件 | 扩展 | 添加数 | 用于 |
|---|---|---|---|
base.json | – 说吧 – | 严格 + 模块集 | 运行时间不可知基底延伸至 |
bun.json | base.json | types: ["bun"] | Bun项目 |
node.json | base.json | types: ["node"] | 节点.js项目 |
base.json 故意不设置 types, (中文(简体) ), include,或 exclude环境
变量只添加环境 types;其他一切都是继承的.
如何安装
无
npm install -D @cffnpwr/tsconfig
或者说
npx jsr add -D @cffnpwr/tsconfig
小时
pnpm add -D @cffnpwr/tsconfig
或者说
pnpm dlx jsr add -D @cffnpwr/tsconfig
阿宝
bun add -D @cffnpwr/tsconfig
或者说
bunx jsr add -D @cffnpwr/tsconfig
德诺
deno add -D npm:@cffnpwr/tsconfig
或者说
deno add -D jsr:@cffnpwr/tsconfig
如何使用
创建一个 tsconfig.json 并扩展匹配运行时间的变体.
include编号 :exclude 未提供,因此设定每个项目.
宾:
{
"extends": "@cffnpwr/tsconfig/bun",
"include": ["src", "*.config.ts"]
}
节点.js:
{
"extends": "@cffnpwr/tsconfig/node",
"include": ["src"]
}
任何其他运行时间, 延长 base 设置 types 自己说:
{
"extends": "@cffnpwr/tsconfig/base",
"compilerOptions": {
"types": ["@cloudflare/workers-types"]
},
"include": ["src"]
}
什麽 base.json 设定和原因
模块系统
| 选项 | 数值 | 为什么 |
|---|---|---|
target 编号 : lib | ESNext | 最新的语法和库类型;下级是捆绑者的工作. |
module | Preserve | 保留 import编号 :require 书面和暗示 moduleResolution: bundler。 。 。 . |
moduleResolution | bundler | 符合 Bun/Vite/tsdown 的分辨率模型 。 明确设定, 即使 Preserve 暗含着它. |
moduleDetection | force | 对待每一个非.d.ts 文件为模块,避免意外全局标注范围. |
esModuleInterop | true | CJS 默认导入的接口( 类型检查行为 Preserve) (中文(简体) ). |
verbatimModuleSyntax | true | 明确兵力 import type;没有隐含的导入去除. |
isolatedModules | true | 保证每个文件自动安全地转接(单文件转接器, ts.transpileModule) (中文(简体) ). |
allowImportingTsExtensions | true | 允许导入 .ts 路径。 要求数 noEmit (或 emitDeclarationOnly),下文予以满足. |
resolveJsonModule | true | 允许导入 .json。 。 。 . |
释放
| 选项 | 数值 | 为什么 |
|---|---|---|
noEmit | true | tsc 仅用于类型检查;构建由捆绑器(Bun / tsdown / Vite)完成. |
declaration 编号 : declarationMap | true | 只有在消费者设定时才生效 noEmit: false 发送 .d.ts 通过 tsc默认情况下 noEmit: true 他们什么也不放 如此一来,就放弃了产量申报,而无需额外配置. |
严格性
| 选项 | 数值 | 为什么 |
|---|---|---|
strict | true | 完全严格的家庭. |
noUncheckedIndexedAccess | true | 添加数 undefined 到索引签名访问结果. |
noImplicitOverride | true | 要求数 override 以压倒一切的民众盟誓. |
noImplicitReturns | true | 旗帜代码路径不返回一个值. |
noFallthroughCasesInSwitch | true | 非空旗帜 switch 掉下来的病例. |
skipLibCheck | true | 跳过类型检查 .d.ts 用于更快构建的文件. |
故意留给电线
noUnusedLocals, (中文(简体) ), noUnusedParameters,以及 noPropertyAccessFromIndexSignature 没有
在这里。 未使用符号和索引存取报告由
@cffnpwr/eslint-config,所以类型检查器
不重复它.