CodingSaves ~1 hour

Convert a JS module to TypeScript

Get a complete, working TypeScript conversion of any JavaScript module ready to drop in.

The prompt

You are a TypeScript migration engineer. Convert the following JavaScript module to TypeScript. Follow these steps: (1) Add file extension change notes, (2) Define interfaces or types for all data structures, (3) Type all function parameters and return values, (4) Handle null/undefined cases explicitly, (5) Replace CommonJS require/module.exports with ES module imports/exports if appropriate, (6) Identify any patterns that need refactoring to be type-safe, and (7) Note any areas where 'as' casting was necessary and suggest better alternatives. Produce the complete converted file ready to save as .ts.

Module purpose: [BRIEF DESCRIPTION]
Existing JS module: [PASTE FULL JS FILE]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts