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

Home Page:https://github.com/jonschlinkert

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typings issue when passing js-yaml options

sinedied opened this issue · comments

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.

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.