.yaml 和 .yml 导入。
config.yaml
像导入其他源文件一样导入该文件。
config.ts
你也可以通过命名导入解构顶层属性:
config.ts
Bun 还支持 Import Attributes 语法:
config.ts
要在运行时解析 YAML 字符串,可以使用
Bun.YAML.parse():
config.ts
TypeScript 支持
要为 YAML 导入添加 TypeScript 支持,请创建一个在 YAML 文件名后附加.d.ts 的声明文件(例如,config.yaml → config.yaml.d.ts):
config.yaml.d.ts
请参阅 YAML。