TypeStat

JoshuaKGoldbergMIT活跃维护

把 JavaScript 代码自动转换成 TypeScript,也能给已有的 TypeScript 补全类型、修正类型问题,让代码类型更严格。

Converts JavaScript to TypeScript and TypeScript to better TypeScript. 🧫

0.8.17发布于 2025-02-17 00:37 UTC2,255star46fork同步于 2026-11-10 11:44 UTC

怎么上手

由 README 提炼,执行前请确认
npx typestat
npx typestat --config typestat.json
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把 JavaScript 转成 TypeScript、把 TypeScript 改得更严格的 CLI 工具

把 JavaScript 代码自动转换成 TypeScript,也能给已有的 TypeScript 补全类型、修正类型问题,让代码类型更严格。

核心能力

  • 内置 mutator 只增删类型,不改运行时行为
  • 一次把 JavaScript 文件转换为 TypeScript
  • 为刚转换的文件补全 TypeScript 类型
  • 推断类型以修复 noImplicitAny 与 noImplicitThis 违规
  • 为缺失的 null 和 undefined 补注解,便于启用 strictNullChecks

容易踩的坑

首次运行会进入交互式向导生成 typestat.json,之后需显式用 --config 指定配置文件;过滤器依赖 tsquery 语法,配置前需先读 docs 中的 Filters 文档

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本0.8.17
  1. 0.8.17v0.8.17最新正式版2025-02-17 · 2025-02-17 00:37 UTC

    What's Changed

    Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.16...0.8.17

  2. 0.8.16v0.8.162025-02-07 · 2025-02-07 14:23 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.15...0.8.16

  3. 0.8.15v0.8.152025-02-06 · 2025-02-06 18:02 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.14...0.8.15

  4. 0.8.14v0.8.142025-02-06 · 2025-02-06 17:51 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.13...0.8.14

  5. 0.8.13v0.8.132025-02-06 · 2025-02-06 17:48 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/JoshuaKGoldberg/TypeStat/compare/0.8.12...0.8.13

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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:

    1. Usage.md for an explanation of how TypeStat works
    2. Fixes.md for the type of fixes TypeStat will generate mutations for
    3. Cleanups.md for the post-fix cleaning TypeStat may apply to files
    4. Types.md for configuring how to work with types in mutations
    5. Filters.md for using tsquery to ignore sections of source files
    6. 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.