gray-matter
gray-matter copied to clipboard
fix(gray-matter.d.ts): fix excerpt declaration
There is a difference from the actual implementation in the type declaration regarding the ‘excerpt’ option.
excerpt?: boolean | ((input: I, options: O) => string) // <- wrong
excerpt?: boolean | ((input: GrayMatterFile<I>, options: O) => string) // <- correct
Encountered the miss match as well and changed the definition to the following:
excerpt?: boolean | ((file: GrayMatterFile<I>, options: O) => unknown);
In addition to updating the input / file value to GrayMatterFile it also loosens the restriction of the return type. Since the output is not used (see the calls here + here) it doesn't matter what is returned. Omitting it makes it more clear that a side effect of extending the file object is expected.