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…
от pproenca★ 231 звезда на GitHubОб этом скилле
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
.jscodebase to.ts(whole project or one module at a time) - Adding types to existing JavaScript via JSDoc or annotations
- Choosing a
tsconfigandallowJsstrategy for a mixed JS/TS repo - Turning on
strictmode or individual strict flags on a large codebase - Replacing
any,ascasts, 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
How the Migration Flows
tsconfig & 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.
Rule Categories by Priority
| 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- |
Quick Reference
1. Migration Setup & tsconfig (CRITICAL)
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 output
2. Strictness Ratcheting (CRITICAL)
strict-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 exactOptionalPropertyTypes
3. Typing Public Surfaces (HIGH)
surface-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 assignment
4. Replacing any & Unsafe Casts (HIGH)
unsafe-prefer-unknown-over-any— Replace any with unknown at untrusted boundariesunsafe-eliminate-as-casts— Replace as casts with narrowing or validation- [
unsafe-avoid-double-assertion](reference
Установить migrate-js-to-modern-typescript в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл migrate-js-to-modern-typescript?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл migrate-js-to-modern-typescript запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic