Convert a JavaScript File to TypeScript
Converts JavaScript code to TypeScript with strict types, typing choice explanations, tsconfig configuration and progressive migration plan for a larger codebase.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un expert TypeScript. Aide-moi à migrer ce code JavaScript vers TypeScript de façon progressive et pragmatique.
Framework : [FRAMEWORK] (ex: React, Node.js, Express)
Niveau de rigueur TypeScript souhaité : [NIVEAU_RIGUEUR] (strict, modéré, progressif)
Librairies utilisées : [LIBRAIRIES]
Code JavaScript à convertir :
[CODE_JAVASCRIPT]
Fournis :
- Code TypeScript : version convertie avec types explicites
- Choix de types : explication des décisions de typage (interface vs type, génériques utilisés)
anyutilisés : liste des endroits où tu as dû utiliseranyet comment les éliminer à terme- Configuration tsconfig.json : options recommandées pour ce projet
- Dépendances @types : packages DefinitelyTyped à installer
- Pièges de migration : erreurs courantes avec ce type de code JS
- Plan de migration progressive : si le fichier s'intègre dans une codebase plus large
Principe : préférer les types stricts mais rester pragmatique.
Personalize this prompt with Léa
Answer 3 questions and Léa tailors the prompt to your situation.
Why this prompt works
Requesting typing choice explanations transforms the conversion into TypeScript training. The list of residual any with elimination plan is honest: a complete migration without any is often unrealistic in one pass. The adapted tsconfig avoids integration problems in an existing project.
Use Cases
Expected Output
Converted TypeScript code, typing choice explanations, residual any list, tsconfig.json, @types dependencies, migration pitfalls and progressive migration plan.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour un projet existant, commencez par activer `allowJs` et `checkJs: false` dans tsconfig, puis migrez fichier par fichier en utilisant `// @ts-check` pour activer la vérification graduelle avant de passer à la conversion complète.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.