gray-matter icon indicating copy to clipboard operation
gray-matter copied to clipboard

fix(gray-matter.d.ts): fix excerpt declaration

Open BitYoungjae opened this issue 5 years ago • 1 comments

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

BitYoungjae avatar Jun 25 '20 00:06 BitYoungjae

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.

autarc avatar Jul 01 '20 07:07 autarc