Biblioteca de prompts

Prompts de JavaScript

Prompts para JavaScript y TypeScript: añadir tipos a código sin tipar, desenredar promesas y explicar módulos desconocidos.

Los prompts están en inglés, el idioma en que se escribieron y probaron. Las descripciones y las instrucciones de estas páginas están traducidas.

  • typescript
  • migration
  • types
100/100 · 144 tokens

Convertir JavaScript a TypeScript

Añade tipos a un módulo de JavaScript sin cambiar su comportamiento y lista lo que no pudo tipar.

Úsalo cuando: Al migrar un módulo a TypeScript archivo por archivo, cuando necesitas que el resultado compile en modo estricto.

prompt
You are a senior TypeScript engineer migrating JavaScript to TypeScript.

## Task
Convert the JavaScript module below to TypeScript that compiles with strict mode enabled.

## Requirements
- Do not change runtime behavior, names, or exports.
- Never use the any type; use unknown and narrow it where a type cannot be known.
- Define an interface or type alias for every object shape used more than once.
- Add explicit return types to every exported function.

## Output format
Return one TypeScript code block containing the converted module, followed by a bulleted list of every place where you used unknown and what information would let it be typed precisely.

## Input
<module>
{{module}}
</module>

Variables

{{module}}
El código fuente JavaScript que convertir.

Entrada de ejemplo

module: a utils.js file exporting formatPrice(amount, currency) and parseOrder(json).

Salida de ejemplo

```ts
export function formatPrice(amount: number, currency: string): string { ... }
export function parseOrder(json: string): Order { ... }
```
- `parseOrder`: the parsed value is `unknown` until validated; a schema for Order would allow a precise type.

Ilustrativa: escrita para mostrar la forma esperada, no generada por un modelo.

  • code reading
  • onboarding
  • documentation
100/100 · 171 tokens

Explicar un módulo desconocido

Explica qué hace un módulo, sus entradas y salidas y dónde es arriesgado modificarlo.

Úsalo cuando: Has heredado código y necesitas entenderlo antes de editarlo.

prompt
You are a senior JavaScript engineer explaining code to a colleague who is new to the codebase.

## Task
Explain what the module below does and how to change it safely.

## Requirements
- Describe only what the code does; do not guess at intent that the code does not show.
- List every exported function with its parameters, return value, and side effects.
- Name the 3 places where a change is most likely to break callers, and say why.
- Use plain language and define any term a new team member may not know.

## Output format
Return markdown with three sections: What it does (at most 4 sentences), Exports (a table with the columns Name, Parameters, Returns, and Side effects), and Risky to change (numbered list).

## Input
<module>
{{module}}
</module>

Variables

{{module}}
El código fuente del módulo.

Entrada de ejemplo

module: a cache.js file that wraps fetch with an in-memory Map and a TTL.

Salida de ejemplo

## What it does
Wraps `fetch` so repeated GET requests within 60 seconds return a stored response...

## Exports
| Name | Parameters | Returns | Side effects |
|---|---|---|---|
| cachedFetch | url, options | Promise<Response> | Writes to the module-level Map |

Ilustrativa: escrita para mostrar la forma esperada, no generada por un modelo.

Hazlo tuyo

Edita los requisitos para que se ajusten a tus estándares y revisa el resultado. El analizador de prompts vuelve a puntuarlo mientras escribes, el optimizador elimina el relleno sin perder ningún requisito y el escáner de seguridad marca secretos y datos personales antes de que lo envíes a un modelo.

Más categorías