docs: Add TypeScript support documentation for YAML imports (#22675)

This commit is contained in:
robobun
2025-09-15 00:30:59 -07:00
committed by GitHub
parent 6397654e22
commit 0ec153ee1c
2 changed files with 65 additions and 0 deletions

View File

@@ -73,4 +73,30 @@ console.log(data.hobbies); // => ["reading", "coding"]
---
## TypeScript Support
To add TypeScript support for your YAML imports, create a declaration file with `.d.ts` appended to the YAML filename (e.g., `config.yaml` → `config.yaml.d.ts`);
```ts#config.yaml.d.ts
const contents: {
database: {
host: string;
port: number;
name: string;
};
server: {
port: number;
timeout: number;
};
features: {
auth: boolean;
rateLimit: boolean;
};
};
export = contents;
```
---
See [Docs > API > YAML](https://bun.com/docs/api/yaml) for complete documentation on YAML support in Bun.