Files
tsl-devkit/docs/typescript/configuration.md
T
csh 35e6a301aa Squashed 'docs/standards/playbook/' changes from 8b75747..c3f8137
c3f8137 📦 deps(skills): sync superpowers
35e827d 📦 deps(skills): sync superpowers
e546ffb 📦 deps(skills): sync superpowers
f7f2c57 🔧 chore(ci): use ci-bot identity for superpowers sync commits
fa247a7 📦 deps(skills): sync superpowers
a97c333 🔧 chore(ci): add resilient upstream fetch fallback for superpowers update
484f9d3 🔧 chore(ci): automate thirdparty superpowers refresh and sync base
c19e53e 📝 docs(playbook): refresh guidance and examples
52046b4 📝 docs(prompts): add code-review template and align docs flow
9ac8a4c 📝 docs(typescript): clarify ts and js support boundaries
1f46203  feat(typescript): add standards docs and sync rewrite coverage
872c1af 🔧 feat(skills): install to agents home

git-subtree-dir: docs/standards/playbook
git-subtree-split: c3f81371e24d63b603de9b6eb92bf7e4c453a2b4
2026-03-04 15:56:21 +08:00

1.6 KiB
Raw Blame History

TypeScript 配置清单

本文件汇总 TypeScript 项目常用配置文件说明。

1) tsconfig.json

关键编译选项:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "exactOptionalPropertyTypes": true,
    "skipLibCheck": true,
    "outDir": "dist",
    "rootDir": "src"
  },
  "include": ["src"]
}
  • strict: true:启用全部严格检查(必须)
  • noUncheckedIndexedAccess:数组/对象索引访问返回 T | undefined(推荐)
  • skipLibCheck:跳过 .d.ts 检查,加快编译

2) .prettierrc

{
  "semi": false,
  "singleQuote": true,
  "printWidth": 100,
  "trailingComma": "all",
  "tabWidth": 2
}

3) eslint.config.jsFlat Config

import tseslint from 'typescript-eslint'

export default tseslint.config(
  ...tseslint.configs.recommendedTypeChecked,
  {
    languageOptions: {
      parserOptions: { projectService: true },
    },
    rules: {
      '@typescript-eslint/no-explicit-any': 'error',
      '@typescript-eslint/no-floating-promises': 'error',
    },
  },
)

4) .editorconfig

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{ts,tsx,js,jsx,json}]
indent_style = space
indent_size = 2
max_line_length = 100

5) .vscode/settings.json

{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.rulers": [100],
  "typescript.tsdk": "node_modules/typescript/lib"
}