# JavaScript to TypeScript Migration (Node/Express)

> Convert a JavaScript (CommonJS) Node.js/Express backend to TypeScript one file at a time, with no build step, using Node 22.18+/24 type stripping. Sets up tsc in CI, converts safely in small revertable PRs, and blocks hand-written types, ! / as casts and silent skipLibCheck.

JavaScript to TypeScript Migration (Node/Express) is a paid AI agent skill on Agensi by Sohail, in APIs & Backend. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $7 (one-time purchase)
- Creator: [Sohail](https://www.agensi.io/creators/muhammad-sohail)
- Category: [APIs & Backend](https://www.agensi.io/skills/apis-backend)
- Version: 1.0
- Last updated: 2026-11-27
- Security: scan passed (2026-11-27); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/javascript-to-typescript-migration-node-express
- Tags: api, code-review, typescript, javascript-to-typescript, nodejs, express, migration

## 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 --noEmit` checks the mixed `.js` / `.ts` codebase on every PR.
- **One file at a time.** `git mv`, add types without changing logic, update every `require('./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 `.js` in TypeScript-only folders, hand-type a `require()`, add `!` or `as` to silence the compiler, rewrite a package's types with `declare module`, or turn on `skipLibCheck` without 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 documented `skipLibCheck`. 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 `.ts` safely
- Audit a migration someone (or an AI agent) already did: hand-written library types, unchecked typed requires, `!`/`as` added 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.

## Requires

- Node.js
- tsc
- Git

## Known limitations

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 this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the JavaScript to TypeScript Migration (Node/Express) skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does this skill do?

It converts a JavaScript (CommonJS) Node.js/Express backend to TypeScript one file at a time, in small revertable PRs, with production behaviour unchanged. Node runs the .ts files directly via type stripping, so there is no build step.

### Strict mode already passes on my migration. Is it fine?

Not necessarily. A typed require like const x: Foo = require(...) is never checked against the real module, and hand-written library types compile while being wrong. Ask the skill to audit the migration: it counts hand-typed requires, fake library interfaces and added !/as casts.

### Why not just let my AI agent convert the files?

Agents are very good at making the compiler quiet: hand-writing a library's types, adding casts, or adding ?? '' and early returns that change API responses. This skill gives the agent house rules and a PR check that fails on exactly those shortcuts.

### Do I need a build step or ESM?

No. The repo stays CommonJS and Node 22.18+/24 runs .ts files directly. tsc --noEmit only type-checks in CI, so load order for dotenv and APM agents is untouched.

### What if my library types fail to compile, like old Mongoose?

The skill works through it library by library: the package's own types, then @types, then version fixes, and only then a documented skipLibCheck. It never hand-writes the library's types.

### Which agents does it work with?

Any agent that reads SKILL.md, including Claude Code, Codex CLI, Cursor and Gemini CLI.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
