MCPcopy Index your code
hub / github.com/JoshuaKGoldberg/TypeStat

github.com/JoshuaKGoldberg/TypeStat @0.8.17

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.8.17 ↗ · + Follow
1,121 symbols 2,088 edges 311 files 2 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TypeStat

Converts JavaScript to TypeScript and TypeScript to better TypeScript. 🧫

<a href="#contributors" target="_blank"><img alt="👪 All Contributors: 14" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-14-21bb42.svg" /></a>


<a href="https://github.com/JoshuaKGoldberg/TypeStat/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
<a href="https://codecov.io/gh/JoshuaKGoldberg/TypeStat" target="_blank"><img alt="🧪 Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/TypeStat?label=%F0%9F%A7%AA%20coverage" /></a>
<a href="https://github.com/JoshuaKGoldberg/TypeStat/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg"></a>
<a href="http://npmjs.com/package/typestat"><img alt="📦 npm version" src="https://img.shields.io/npm/v/typestat?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
<img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />

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:

  • ✨ Convert JavaScript files to TypeScript in a single bound!
  • ✨ Add TypeScript types on files freshly converted from JavaScript to TypeScript!
  • ✨ Infer types to fix --noImplicitAny and --noImplicitThis violations!
  • ✨ Annotate missing nulls and undefineds to get you started with --strictNullChecks!

⚡ To start, the typestat command will launch an interactive guide to setting up a configuration file. ⚡

npx typestat

shell 👋 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

Beyang Liu Beyang Liu 💻 Daniel Stiner Daniel Stiner 🐛 Deleted user Deleted user 🚧 Emerson Emerson 💻 Girish Sontakke Girish Sontakke 💻 Guten Guten 🐛 Ibrahim H. Ibrahim H. 💻
Josh Goldberg ✨ Josh Goldberg ✨ 🚧 🐛 🔧 💻 🚇 📖 Loren Van Spronsen Loren Van Spronsen 💻 Mark Molinaro Mark Molinaro 🐛 💻 Nigel Gilbert Nigel Gilbert 🐛 Peter A. Jonsson Peter A. Jonsson 🐛 💻 orionna319 orionna319 🐛 rubiesonthesky rubiesonthesky 🐛 🚧 🔧 💻 ⚠️

💙 This package is based on @JoshuaKGoldberg's TypeStat.

Extension points exported contracts — how you extend this code

SampleInterface (Interface)
(no doc) [2 implementers]
test/cases/fixes/noImplicitAny/variableDeclarations/original.ts
ConfigurationErrorResult (Interface)
(no doc)
src/index.ts
ProcessOutput (Interface)
(no doc)
src/output/types.ts
CliRuntime (Interface)
(no doc)
src/cli/runCli.ts
OptionsFromRawOptionsSettings (Interface)
(no doc)
src/options/fillOutRawOptions.ts
LanguageServices (Interface)
(no doc)
src/services/language.ts
GenericClassDetails (Interface)
(no doc)
src/mutators/builtIn/fixIncompleteTypes/fixIncompleteImplicitGenerics/fixIncompleteImplicitVariableGenerics/getGenericClassDetails.ts
MutationTestResult (Interface)
(no doc)
src/tests/testSetup.ts

Core symbols most depended-on inside this repo

getTypeAtLocationIfNotError
called by 58
src/shared/types.ts
runMutationTest
called by 49
src/tests/testSetup.ts
collectMutationsFromNodes
called by 26
src/mutators/collectMutationsFromNodes.ts
addAndCheck
called by 16
src/runtime/providers/tracking/WaveTracker.ts
get
called by 14
src/services/LazyCache.ts
getNodeReferencesAsNodes
called by 14
src/shared/FileInfoCache.ts
takesString
called by 13
test/cases/fixes/strictNonNullAssertions/callExpressions/original.ts
takesString
called by 13
test/cases/fixes/strictNonNullAssertions/callExpressions/expected.ts

Shape

Function 711
Class 244
Interface 92
Method 61
Enum 13

Languages

TypeScript100%

Modules by API surface

test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitClassGenerics/original.ts38 symbols
test/cases/fixes/incompleteTypes/implicitGenerics/incompleteImplicitClassGenerics/expected.ts38 symbols
test/cases/fixes/noInferableTypes/parameters/original.ts28 symbols
test/cases/fixes/noInferableTypes/parameters/expected.ts28 symbols
test/cases/fixes/strictNonNullAssertions/propertyAccesses/original.ts26 symbols
test/cases/fixes/strictNonNullAssertions/propertyAccesses/expected.ts26 symbols
test/cases/fixes/incompleteTypes/returnTypes/original.ts26 symbols
test/cases/fixes/incompleteTypes/returnTypes/expected.ts26 symbols
test/cases/fixes/incompleteTypes/propertyDeclarationTypes/original.ts25 symbols
test/cases/fixes/incompleteTypes/propertyDeclarationTypes/expected.ts25 symbols
test/cases/fixes/incompleteTypes/reactTypes/reactPropsMissing/expected.tsx23 symbols
test/cases/fixes/strictNonNullAssertions/returnTypes/original.ts18 symbols

For agents

$ claude mcp add TypeStat \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact