Individual skill
migrate-js-to-modern-typescript
Migrating 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 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.
skills/.experimental/migrate-js-to-modern-typescript/SKILL.md
Source commit cf93c57cac89d6fc3e4194686000411567f5caf3
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- No
- Repository scan complete
- No
- Skill scan complete
- No
- Observed behavior
- Not checked yet
- Last checked
- Nov 5, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 222
- Repository last updated
- Aug 15, 2026
- License
- MIT
Observed agent integration: codex
- engineering Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
AGENTS.mddoc · 9,632 bytesSKILL.mdcore · 9,652 bytesSKILL.mdcore · 9,652 bytesassets/templates/_template.mddoc · 1,265 bytesmetadata.jsonasset · 1,274 bytesreferences/_sections.mddoc · 2,508 bytesreferences/idiom-default-export-to-named.mddoc · 1,239 bytesreferences/idiom-enum-to-union-or-const.mddoc · 1,474 bytesreferences/idiom-optional-chaining-over-guards.mddoc · 1,179 bytesreferences/idiom-prototype-to-class.mddoc · 1,188 bytesreferences/idiom-replace-arguments-object.mddoc · 1,132 bytesreferences/idiom-require-to-import.mddoc · 1,076 bytesreferences/idiom-type-only-imports.mddoc · 1,329 bytesreferences/runtime-derive-types-from-schemas.mddoc · 1,250 bytesreferences/runtime-type-environment-variables.mddoc · 1,299 bytesreferences/runtime-type-guards-at-boundaries.mddoc · 1,528 bytesreferences/runtime-type-json-parse.mddoc · 1,261 bytesreferences/runtime-validate-external-data.mddoc · 1,310 bytesreferences/setup-allowjs-checkjs-bridge.mddoc · 1,522 bytesreferences/setup-jsdoc-before-rename.mddoc · 1,471 bytesreferences/setup-migrate-leaves-first.mddoc · 1,687 bytesreferences/setup-modern-module-resolution.mddoc · 1,405 bytesreferences/setup-noemitonerror-isolatedmodules.mddoc · 1,233 bytesreferences/setup-prefer-ts-expect-error.mddoc · 1,430 bytesreferences/setup-skiplibcheck-during-migration.mddoc · 1,399 bytesreferences/strict-enable-flags-incrementally.mddoc · 1,371 bytesreferences/strict-exact-optional-property-types.mddoc · 1,459 bytesreferences/strict-no-implicit-any.mddoc · 1,116 bytesreferences/strict-no-unchecked-indexed-access.mddoc · 1,549 bytesreferences/strict-prioritize-null-checks.mddoc · 1,328 bytesreferences/strict-use-unknown-in-catch.mddoc · 1,077 bytesreferences/surface-annotate-exported-signatures.mddoc · 1,362 bytesreferences/surface-interface-for-object-args.mddoc · 1,222 bytesreferences/surface-replace-jsdoc-with-types.mddoc · 1,272 bytesreferences/surface-type-callbacks.mddoc · 1,178 bytesreferences/surface-type-class-fields.mddoc · 1,325 bytesreferences/surface-type-default-params.mddoc · 1,224 bytesreferences/tooling-declare-untyped-modules.mddoc · 1,316 bytesreferences/tooling-emit-declaration-files.mddoc · 1,244 bytesreferences/tooling-install-types-packages.mddoc · 1,165 bytesreferences/tooling-typecheck-in-ci.mddoc · 1,145 bytesreferences/tooling-use-tsx-over-ts-node.mddoc · 1,192 bytesreferences/unsafe-avoid-double-assertion.mddoc · 1,186 bytesreferences/unsafe-eliminate-as-casts.mddoc · 1,195 bytesreferences/unsafe-narrow-instead-of-nonnull.mddoc · 1,357 bytesreferences/unsafe-prefer-unknown-over-any.mddoc · 1,333 bytesreferences/unsafe-replace-function-type.mddoc · 1,286 bytesreferences/unsafe-type-dynamic-property-access.mddoc · 1,354 bytes
Read excerpt
# JavaScript to TypeScript Migration Best Practices
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.
## When to Apply
Reference these guidelines when:
- Converting a `.js` codebase to `.ts` (whole project or one module at a time)
- Adding types to existing JavaScript via JSDoc or annotations
- Choosing a `tsconfig` and `allowJs` strategy for a mixed JS/TS repo
- Turning on `strict` mode or individual strict flags on a large codebase
- Replacing `any`, `as` casts, and `!` assertions left over from a quick conversion
- Validating external data (JSON, env, API responses) so the types you wrote are true at runtime
- Converting CommonJS to ESM, prototypes to classes, and other JS idioms to TS
- Updating the build, runner, and CI to type-check and publish TypeScript