プロンプトライブラリ

JavaScriptのプロンプト

JavaScript と TypeScript 向けのプロンプト:型のないコードへの型付け、Promise の整理、見慣れないモジュールの解説。

プロンプト本体は、作成・テストした言語である英語です。これらのページの説明と案内文は翻訳されています。

  • typescript
  • migration
  • types
100/100 · 144 トークン

JavaScript を TypeScript に変換

動作を変えずに JavaScript モジュールへ型を追加し、型付けできなかった箇所を一覧にします。

使う場面: モジュールを 1 ファイルずつ TypeScript に移行し、strict モードでコンパイルできる結果がほしいとき。

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>

変数

{{module}}
変換する JavaScript のソース。

入力例

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

出力例

```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.

例示です。期待される形を示すために書いたもので、モデルが生成したものではありません。

  • code reading
  • onboarding
  • documentation
100/100 · 171 トークン

見慣れないモジュールの解説

モジュールが何をするか、入力と出力、変更すると危険な箇所を説明します。

使う場面: コードを引き継ぎ、編集する前に理解する必要があるとき。

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>

変数

{{module}}
モジュールのソース。

入力例

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

出力例

## 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 |

例示です。期待される形を示すために書いたもので、モデルが生成したものではありません。

自分用に調整する

要件を自分の基準に合わせて編集し、結果をチェックしましょう。プロンプトアナライザーは入力に合わせて再採点し、オプティマイザーは要件を落とさずに冗長な表現を削り、セキュリティスキャナーはモデルに送る前に秘密情報や個人データを検出します。

その他のカテゴリ