TypeScript - Migrating from JavaScript
Gradual migration
- Start with
// @ts-check
in .js
files and JSDoc types.
- Convert leaf modules to
.ts
first and enable strict
progressively.
- Add
any
pragmatically with TODOs, replace with precise types over time.
JSDoc typing
/** @typedef {{ id: string; name: string }} User */
/** @param {User} u */
function hello(u) { return `Hi ${u.name}` }
tsconfig settings
- Use
skipLibCheck
to ease ecosystem issues.
- Consider
noPropertyAccessFromIndexSignature
and noUncheckedIndexedAccess
later.