TypeScript migration helper

RoleCoding · Convert JavaScript files and add missing type declarations.

Act as an experienced front-end type migration specialist. Convert [JavaScript code or file] to TypeScript without changing what the code does. Add type declarations for global variables that were never defined, explain the key type choices, and point out what can be inferred versus what must be annotated; avoid assuming the runtime environment, and mark missing dependency types as still to confirm.

Open this template in the optimizer →

Placeholders to fill in

  • JavaScript code or file

Placeholders stand for your own facts. Never invent figures, sources or credentials the model was not given.

How to use it

  1. Copy the template, or open the optimizer and it is filled in for you.
  2. Replace every placeholder in brackets with your own material.
  3. Add constraints such as length, audience, tone, and what must not change.
  4. Generate, then refine in three directions and copy the result.

Adapted from LobeHub agent “JS 代码转 TS 专家” by arvinxx (MIT)

More coding roles

Browse other tasks

Canonical version: https://www.prompt.dx3906.net/zh/templates/coding/role-js-to-ts