- Home
- Skills
- APIs & Backend
- JavaScript to TypeScript Migration (Node/Express)
Works with the AI Agents you already use
JavaScript to TypeScript Migration (Node/Express)
by Sohail
Converts your JavaScript codebase to TypeScript without fake types.
$7
JavaScript to TypeScript Migration (Node/Express)
Example session with this skill installed
Convert src/services/cache.service.js in our Express + Mongoose API to TypeScript. We run Node 24 in production. Don't change any behaviour.
- Read your context and instructions
- Compiled the javascript to typescript
Summary
Converted cache.service.js to cache.service.ts with no behaviour change. Node 24 runs it directly via type stripping, so there is no build step. One PR, revertable on its own.
What changed
| File | Change |
|---|---|
src/services/cache.service.js → .ts | git mv, types added, logic identical |
src/controllers/user.controller.js | require('../services/cache.service.ts') |
src/controllers/product.controller.js | require('../services/cache.service.ts') |
tests/cache.service.test.js | stub regex cache.service(\.js)?$ → cache.service(\.ts)?$ |
.github/ts-migration.json | removed from inProgress |
The converted module
const redis: typeof import('ioredis') = require('ioredis');
const client = new redis(process.env.REDIS_URL);
async function get<T = any>(key: string): Promise<T | null> {
const raw = await client.get(key);
return raw ? JSON.parse(raw) : null;
}
async function set(key: string, value: unknown, ttl = 300): Promise<void> {
await client.set(key, JSON.stringify(value), 'EX', ttl);
}
async function del(key: string): Promise<void> {
await client.del(key);
}
const service = { get, set, del };
module.exports = service;
export type CacheService = typeof service;
Still CommonJS, erasable syntax only, library type derived with typeof import('ioredis'), no ! or as added. Callers can now type it with import type { CacheService } from './cache.service.ts'.
Verified
npm run typecheck: clean- Unit tests: 142 passing, same as before
- Added a test pinning the cache key names and JSON encoding
node -e "require('./src/services/cache.service.ts')"in the production image: loads, no warnings- Migration-rules check: green
Next steps
helpers/format.js and services/mailer.service.js are leaves and ready now; user.service.js waits on this PR. Merge, then say "continue".
Connects securely to your tools. The creator never sees your data.
About this skill
Converts your JavaScript codebase to TypeScript without fake types.
The problem it solves
Let an AI agent convert a Node/Express API to TypeScript and it will make the compiler happy, but not always honestly. In one real 219-file migration, strict mode and CI were green on every PR. Underneath: about 530 lines of hand-written fake library types, 88 const x: T = require(...) lines that check nothing, and 246 as casts. It all started from one compiler error inside node_modules that a single skipLibCheck would have fixed. The first shortcut became the template for every module after it, and "strict mode passes" hid it all.
On top of that, extra-strict flags on loose types pushed hundreds of ?? '' and early-return edits, quietly turning 500s into 404s and nulls into missing keys, breaking callers that depended on the old responses.
This skill makes the agent do the conversion the way an experienced TypeScript engineer would, and adds a PR check so the shortcuts can't come back.
How it works
- No build step. New and converted files are
.ts, and Node 22.18+/24 runs them directly by stripping types. The repo stays CommonJS, so dotenv and APM load order is untouched. - Type checking in CI.
tsc --noEmitchecks the mixed.js/.tscodebase on every PR. - One file at a time.
git mv, add types without changing logic, update everyrequire('./x.ts'), fix test stubs keyed on the old path, and verify the file loads in the production image. - A migration-rules PR check that fails PRs which add new
.jsin TypeScript-only folders, hand-type arequire(), add!orasto silence the compiler, rewrite a package's types withdeclare module, or turn onskipLibCheckwithout saying why. - Library types done properly. Uses the package's own types or
@types, works through version fixes library by library, and only then falls back to a documentedskipLibCheck. Never hand-written interfaces for a library. - Phased plan. Type checking only → guardrails → leaf modules → optional ORM upgrade → models (Mongoose generics) → routes and controllers → tighten strict flags.
- Works in rounds. A status script shows what's ready to convert, what's waiting and on which files, and which files belong in one PR, so several PRs can be open at once and merge in any order.
Use it to
- Plan or run a JS → TS migration of a Node/Express/Mongoose backend
- Write a new file in TypeScript inside a JavaScript repo
- Convert "just this one service" to
.tssafely - Audit a migration someone (or an AI agent) already did: hand-written library types, unchecked typed requires,
!/asadded to silence errors, or "strict passes, so is it fine?"
Requirements
Node.js 22.18+ or 23.6+ (Node 24 recommended), a CommonJS codebase, Git. MIT licensed.
Targets CommonJS Node.js codebases. Needs Node 22.18+/23.6+ in production for no-build type stripping (older Node needs the dist/ fallback). Enums, namespaces and parameter properties are not allowed in converted files, since Node can only strip erasable syntax. ESM-first repos are not covered.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 7 days ago
- Software
Node.jstsc
Git
Permissions
Shell to run git, npm, tsc and tests; read and write files to rename .js to .ts, add types, update requires and add the tsconfig, CI workflow and migration-check script.
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.