jonschlinkert / gray-matter

Smarter YAML front matter parser, used by metalsmith, Gatsby, Netlify, Assemble, mapbox-gl, phenomic, vuejs vitepress, TinaCMS, Shopify Polaris, Ant Design, Astro, hashicorp, garden, slidev, saber, sourcegraph, and many others. Simple to use, and battle tested. Parses YAML by default but can also parse JSON Front Matter, Coffee Front Matter, TOML Front Matter, and has support for custom parsers. Please follow gray-matter's author: https://github.com/jonschlinkert
https://github.com/jonschlinkert
MIT License
3.93k stars 138 forks source link

Typings issue when passing js-yaml options #107

Open sinedied opened 4 years ago

sinedied commented 4 years ago

When trying to pass js-yaml options to stringify method, there is a type error:

matter.stringify(file, file.data, { lineWidth: -1 });
// >Type '{ lineWidth: number; }' has no properties in common with type 'GrayMatterOption<string, GrayMatterOption<string, unknown>>'.ts(2559)

Since any kind of options (depending of the engine) can be passed here, the GrayMatterOption type is missing something here (or maybe I missed something?).

Thanks for helping.

chmac commented 2 years ago

I have the same issue, passing {skipInvalid: true} as an option is passed to js-yaml, but the typescript types fail.

Workaround seems to be casting the options to any like matter.stringify(a, b, {skipInvalid: true} as any), but if the types also merged in the js-yaml types that would be awesome.