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