Convert a JavaScript file or module to TypeScript with types inferred from real usage, a recommended tsconfig, a list of bugs the types reveal and a plan for the rest of the codebase.
Redesign your TypeScript domain types so impossible states do not compile: discriminated unions, branded IDs, exhaustive switches and validation at system boundaries.