Excerpt type definition seems wrong
wkirby opened this issue · 1 comments
wkirby commented
The type for excerpt
is declared as:
type Input = string | Buffer
interface GrayMatterOption<
I extends Input,
O extends GrayMatterOption<I, O>
> {
parser?: () => void
eval?: boolean
excerpt?: boolean | ((input: I, options: O) => string)
excerpt_separator?: string
engines?: {
[index: string]:
| ((input: string) => object)
| { parse: (input: string) => object; stringify?: (data: object) => string }
}
language?: string
delimiters?: string | [string, string]
}
But the example function usage in the README is:
function firstFourLines(file, options) {
file.excerpt = file.content.split('\n').slice(0, 4).join(' ');
}
This example function does not take a string or a Buffer — it takes a GrayMatterFile
and doesn't appear to return anything.
The type, I think, should be redeclared as:
excerpt?: boolean | ((file: GrayMatterFile, options: O) => void)