typescript-strict-mode
它能做什么
这项技能检查 TypeScript 项目的设置,并开启严格的类型检查。适用于希望编译器在代码运行前捕捉更多错误的开发者。
适用场景
- ✓当 TypeScript 项目的 tsconfig.json 中没有严格模式设置的时候。
- ✓当代码库中出现空值错误或隐式 any 类型的时候。
- ✓当你开始新的 TypeScript 项目,并选择最安全的设置的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/typescript-strict-mode/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我有一个 TypeScript 项目。请检查我的 tsconfig,如果安全的话就开启严格模式。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会读取 tsconfig 文件,并检查哪些严格选项已开启。它会开启缺少的选项;如果现有代码有很多错误,则会逐步启用。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Enable TypeScript strict mode in tsconfig.json
Without strict mode, TypeScript allows implicit any types, ignores possible null/undefined values, and silently accepts unsound function assignments — meaning the type system gives a false sense of safety. Enabling strict mode makes TypeScript catch the bugs it was designed to prevent, turning type errors into compile-time failures rather than runtime surprises in production.
Quick Reference
- "strict": true enables strictNullChecks, noImplicitAny, and six other checks
- Enable strict from project start — retrofitting a large codebase is painful
- On existing projects: enable strictNullChecks first, then other flags incrementally
- Strict mode eliminates entire classes of null reference and implicit-any bugs
Check
Inspect the tsconfig.json in this project and report whether "strict": true (or individual strict flags) is enabled. List any missing strict flags.
Fix
Add "strict": true to the compilerOptions in tsconfig.json. If the project has existing type errors, explain how to enable strictNullChecks first as a stepping stone.
Explain
Explain what TypeScript strict mode enables, which individual flags it activates, and why each flag matters for catching real bugs.
Code Review
Check whether the codebase relies on implicit any, unchecked null access, or loose function type assignments that strict mode would reject. Flag the specific patterns and show what stricter types would look like.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/javascript/typescript-strict-mode
常见问题
严格模式会开启什么?
它会启用一组检查,包括 strictNullChecks 和 noImplicitAny,用于捕捉常见错误。
如果我的项目有很多类型错误怎么办?
这项技能建议先启用 strictNullChecks,然后再逐个开启其他选项。
从一开始就开启严格模式更容易吗?
这项技能指出,从一开始就开启严格模式,比之后为大型项目补做要容易得多。
详情
作者的原始描述
Use when setting up a new TypeScript project, auditing an existing tsconfig.json, or reviewing code where null-reference errors or implicit any types are present.
热度
- GitHub 星标
- 75k
- 排名
- #3068
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。