brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
migrate-js-to-modern-typescriptMigrating a JavaScript codebase to TypeScript — converting .js files to .ts, adding types to existing JS, or tightening a loosely-typed TS project toward strict mode. Covers tsconfig and allowJs strategy, incremental strict-flag ratcheting (noImplicitAny, strictNullChecks, noUncheckedIndexedAccess), typing public surfaces, replacing `any` and unsafe casts w…
Independent GitHub snapshot · Automated classification · Original documentation governs
any and unsafe casts with unknown and narrowing, validating runtime boundaries (JSON, env, API responses), converting CommonJS to ESM and prototypes to classes, and the build/CI changes a migration needs. Trigger even when the user only says "add types", "turn on strict mode", or "convert this file to TypeScript", and especially on a mixed JS/TS repo. Distinct from general TypeScript refactoring — this is the migration act itself, performed file by file while keeping the build green.Guide for taking a JavaScript codebase to strict, modern TypeScript without a big-bang rewrite. Contains 42 rules across 7 categories, prioritized by impact to drive an incremental, file-by-file migration that keeps the build compiling at every step.
Reference these guidelines when:
.js codebase to .ts (whole project or one module at a time)tsconfig and allowJs strategy for a mixed JS/TS repostrict mode or individual strict flags on a large codebaseany, as casts, and ! assertions left over from a quick conversiontsconfig & strategy → strictness ratchet → type the surfaces → kill any/casts
→ validate runtime boundaries → convert JS idioms → tooling/build/CI
Decisions at the front cascade: a wrong tsconfig or a top-down conversion order forces you to re-type modules twice, and an early any flood poisons everything downstream. Work from the front of this pipeline and from the leaves of the dependency graph inward.
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Migration Setup & tsconfig | CRITICAL | setup- |
| 2 | Strictness Ratcheting | CRITICAL | strict- |
| 3 | Typing Public Surfaces | HIGH | surface- |
| 4 | Replacing any & Unsafe Casts | HIGH | unsafe- |
| 5 | Runtime Data Validation | MEDIUM-HIGH | runtime- |
| 6 | JS-to-TS Idiom Conversion | MEDIUM | idiom- |
| 7 | Tooling & Build Migration | LOW-MEDIUM | tooling- |
setup-allowjs-checkjs-bridge — Enable allowJs and checkJs for incremental migrationsetup-migrate-leaves-first — Convert dependency leaves before their dependentssetup-jsdoc-before-rename — Type JS with JSDoc and @ts-check before renamingsetup-prefer-ts-expect-error — Prefer @ts-expect-error over @ts-ignore for suppressionssetup-skiplibcheck-during-migration — Set skipLibCheck to silence third-party type noisesetup-modern-module-resolution — Set module and moduleResolution to a modern pairsetup-noemitonerror-isolatedmodules — Enable isolatedModules and noEmitOnError for safe outputstrict-enable-flags-incrementally — Enable strict flags one at a time, not all at oncestrict-prioritize-null-checks — Prioritize strictNullChecks for the highest bug yieldstrict-no-implicit-any — Enable noImplicitAny to surface every untyped valuestrict-no-unchecked-indexed-access — Enable noUncheckedIndexedAccess for index safetystrict-use-unknown-in-catch — Type caught errors as unknown, not anystrict-exact-optional-property-types — Separate missing from undefined with exactOptionalPropertyTypessurface-annotate-exported-signatures — Annotate exported function signatures explicitlysurface-replace-jsdoc-with-types — Replace JSDoc type tags with real annotationssurface-type-default-params — Type default and optional parameters preciselysurface-interface-for-object-args — Convert loose object arguments to named interfacessurface-type-callbacks — Type callback and higher-order parameterssurface-type-class-fields — Declare class field types instead of relying on assignmentunsafe-prefer-unknown-over-any — Replace any with unknown at untrusted boundariesunsafe-eliminate-as-casts — Replace as casts with narrowing or validationunsafe-avoid-double-assertion — Avoid double assertions that force unrelated typesunsafe-type-dynamic-property-access — Type dynamic property access with Records or index signaturesunsafe-replace-function-type — Replace the Function type with specific call signaturesunsafe-narrow-instead-of-nonnull — Narrow values instead of using the non-null assertionruntime-validate-external-data — Validate external data at the boundaryruntime-type-environment-variables — Parse and type environment variables onceruntime-derive-types-from-schemas — Derive static types from runtime schemasruntime-type-guards-at-boundaries — Write type guards for untyped library returnsruntime-type-json-parse — Type JSON.parse results through validationidiom-require-to-import — Convert require and module.exports to ESM syntaxidiom-prototype-to-class — Convert prototype constructors to class syntaxidiom-type-only-imports — Use import type for type-only importsidiom-replace-arguments-object — Replace the arguments object with rest parametersidiom-enum-to-union-or-const — Convert frozen-object enums to const objects or unionsidiom-default-export-to-named — Prefer named exports over default exportsidiom-optional-chaining-over-guards — Replace manual existence guards with optional chainingtooling-declare-untyped-modules — Provide ambient declarations for untyped dependenciestooling-install-types-packages — Install @types packages before casting library returnstooling-use-tsx-over-ts-node — Run TypeScript directly with tsx instead of ts-node flagstooling-emit-declaration-files — Emit declaration files for migrated librariestooling-typecheck-in-ci — Add a type-check step to CI separate from the buildRead individual reference files for detailed explanations and code examples:
typescript-refactor — Refactoring and modernizing code that is already TypeScripttypescript-advanced-patterns — Advanced type-level patterns once the migration is done| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |