首次运行会进入交互式向导生成 typestat.json,之后需显式用 --config 指定配置文件;过滤器依赖 tsquery 语法,配置前需先读 docs 中的 Filters 文档
TypeStat
JoshuaKGoldbergMIT活跃维护把 JavaScript 代码自动转换成 TypeScript,也能给已有的 TypeScript 补全类型、修正类型问题,让代码类型更严格。
Converts JavaScript to TypeScript and TypeScript to better TypeScript. 🧫
npx typestat
npx typestat --config typestat.jsonREADME 未说明
把 JavaScript 转成 TypeScript、把 TypeScript 改得更严格的 CLI 工具
把 JavaScript 代码自动转换成 TypeScript,也能给已有的 TypeScript 补全类型、修正类型问题,让代码类型更严格。
核心能力
- 内置 mutator 只增删类型,不改运行时行为
- 一次把 JavaScript 文件转换为 TypeScript
- 为刚转换的文件补全 TypeScript 类型
- 推断类型以修复 noImplicitAny 与 noImplicitThis 违规
- 为缺失的 null 和 undefined 补注解,便于启用 strictNullChecks
容易踩的坑
- 0.8.17v0.8.17最新正式版2025-02-17 · 2025-02-17 00:37 UTC
What's Changed
- chore(deps): update dependency typescript-eslint to v8.23.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2189
- chore(deps): update pnpm to v10.2.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2190
- chore(deps): update dependency eslint-plugin-package-json to v0.23.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2199
- chore(deps): update pnpm to v10.2.1 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2200
- chore(deps): update dependency eslint-plugin-package-json to v0.23.1 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2201
- chore(deps): update dependency @vitest/eslint-plugin to v1.1.26 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2202
- chore(deps): update eslint monorepo to v9.20.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2203
- chore(deps): update dependency eslint-plugin-package-json to v0.24.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2204
- chore(deps): update dependency @vitest/eslint-plugin to v1.1.27 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2205
- chore(deps): update dependency prettier to v3.5.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2206
- chore(deps): update dependency eslint-plugin-package-json to v0.25.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2207
- chore(deps): update dependency @vitest/eslint-plugin to v1.1.28 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2208
- chore(deps): update dependency eslint-plugin-package-json to v0.26.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2209
- chore(deps): update dependency typescript-eslint to v8.24.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2210
- chore(deps): update node.js to v22.14.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2211
- chore(deps): update dependency knip to v5.44.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2213
- chore(deps): update pnpm to v10.3.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2212
- chore(deps): update dependency eslint to v9.20.1 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2215
- chore(deps): update dependency @vitest/eslint-plugin to v1.1.30 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2216
- chore(deps): update dependency @vitest/eslint-plugin to v1.1.31 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2218
- chore(deps): update dependency @types/node to v22.13.2 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2219
- chore(deps): update dependency prettier to v3.5.1 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2220
- fix: simplify collecting strict TS options by @rubiesonthesky in https://github.com/JoshuaKGoldberg/TypeStat/pull/2196
Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.16...0.8.17
- 0.8.16v0.8.162025-02-07 · 2025-02-07 14:23 UTC
查看更新说明
What's Changed
- docs: add lorenvs as a contributor for code by @allcontributors in https://github.com/JoshuaKGoldberg/TypeStat/pull/2191
- chore(deps): update vitest monorepo to v3.0.5 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2188
- chore(deps): update dependency eslint-plugin-package-json to v0.22.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2193
- chore(deps): update dependency @types/node to v22.13.1 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2195
- chore(deps): update dependency eslint-plugin-perfectionist to v4.8.0 by @renovate in https://github.com/JoshuaKGoldberg/TypeStat/pull/2194
- fix: improve reading tsconfig by @rubiesonthesky in https://github.com/JoshuaKGoldberg/TypeStat/pull/2192
Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.15...0.8.16
- 0.8.15v0.8.152025-02-06 · 2025-02-06 18:02 UTC
查看更新说明
What's Changed
- fix: replace
strip-ansiwithstripVTControlCharactersby @LorenVS in https://github.com/JoshuaKGoldberg/TypeStat/pull/2181
New Contributors
- @LorenVS made their first contribution in https://github.com/JoshuaKGoldberg/TypeStat/pull/2181
Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.14...0.8.15
- fix: replace
- 0.8.14v0.8.142025-02-06 · 2025-02-06 17:51 UTC
查看更新说明
What's Changed
- fix: createJavaScriptConfig should print projectPath instead of project by @rubiesonthesky in https://github.com/JoshuaKGoldberg/TypeStat/pull/2184
Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.13...0.8.14
- 0.8.13v0.8.132025-02-06 · 2025-02-06 17:48 UTC
查看更新说明
What's Changed
- fix: replace builtin-modules package with node's isBuiltin check by @rubiesonthesky in https://github.com/JoshuaKGoldberg/TypeStat/pull/2176
Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.12...0.8.13
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Usage
TypeStat is a CLI utility that modifies TypeScript types in existing code. The built-in mutators will only ever add or remove types and will never change your runtime behavior. TypeStat can:
⚡ To start, the typestat command will launch an interactive guide to setting up a configuration file. ⚡
npx typestat
👋 Welcome to TypeStat! 👋 This will create a new typestat.json for you. ...
After, use typestat --config typestat.json to convert your files.
Configuration
To get a deeper understanding of TypeStat, read the following docs pages in order:
- Usage.md for an explanation of how TypeStat works
- Fixes.md for the type of fixes TypeStat will generate mutations for
- Cleanups.md for the post-fix cleaning TypeStat may apply to files
- Types.md for configuring how to work with types in mutations
- Filters.md for using tsquery to ignore sections of source files
- Custom Mutators.md for including or creating custom mutators
Development
See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md for general tooling documentation.
For understanding the project, see ./docs in general, and especially ./docs/Architecture.md.
Thanks! 💖
Contributors
💙 This package is based on @JoshuaKGoldberg's TypeStat.