You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve YAML documentation with Bun.YAML.stringify and TypeScript typing
- Add Bun.YAML.stringify() documentation with examples using (null, 2) for spacing
- Document space parameter: 2 for readable format, 0 for compact flow style
- Add TypeScript section in Module Import explaining manual .d.ts requirement
- Clarify that unlike JSON, TypeScript doesn't automatically type YAML imports
- Show comprehensive example with nested objects, arrays, and objects in arrays
- Demonstrate YAML anchors & aliases with shared object references
- Fix heading structure: parse examples under parse, stringify as separate section
- Use actual tested Bun output for all examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Unlike JSON files, TypeScript doesn't automatically type YAML imports. Add type definitions by creating a `.d.ts` file with the same name as your YAML file:
237
+
238
+
```tsconfig.yaml.d.tsicon="/icons/typescript.svg"
239
+
constcontents: {
240
+
database: {
241
+
host: string;
242
+
port: number;
243
+
name: string;
244
+
};
245
+
server: {
246
+
port: number;
247
+
timeout: number;
248
+
};
249
+
features: {
250
+
auth: boolean;
251
+
rateLimit: boolean;
252
+
};
253
+
};
254
+
255
+
export=contents;
256
+
```
257
+
196
258
---
197
259
198
260
## Hot Reloading with YAML
@@ -435,6 +497,76 @@ if (parseConfig(migrations).autoRun === "true") {
435
497
}
436
498
```
437
499
500
+
### Generating YAML Files
501
+
502
+
You can use `Bun.YAML.stringify()` to programmatically create YAML configuration files. It handles complex data structures including nested objects, arrays, and objects within arrays. When you reference the same object multiple times, YAML automatically creates anchors (`&`) and aliases (`*`) to avoid duplication:
0 commit comments