From 62a3ba4ecd8689d0e65fc49e904d92739b59326d Mon Sep 17 00:00:00 2001 From: Function <34871211+FunctionDJ@users.noreply.github.com> Date: Sun, 6 Mar 2022 16:52:57 +0100 Subject: [PATCH] Fix #135 --- gray-matter.d.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gray-matter.d.ts b/gray-matter.d.ts index dec9c09..35d4f32 100644 --- a/gray-matter.d.ts +++ b/gray-matter.d.ts @@ -1,3 +1,5 @@ +type MatterShapeTemplate = Record + /** * Takes a string or object with `content` property, extracts * and parses front-matter from the string, then returns an object @@ -15,8 +17,9 @@ */ declare function matter< I extends matter.Input, - O extends matter.GrayMatterOption ->(input: I | { content: I }, options?: O): matter.GrayMatterFile + O extends matter.GrayMatterOption, + MatterShape extends MatterShapeTemplate +>(input: I | { content: I }, options?: O): matter.GrayMatterFile declare namespace matter { type Input = string | Buffer @@ -36,8 +39,8 @@ declare namespace matter { language?: string delimiters?: string | [string, string] } - interface GrayMatterFile { - data: { [key: string]: any } + interface GrayMatterFile { + data: MatterShape content: string excerpt?: string orig: Buffer | I @@ -82,10 +85,10 @@ declare namespace matter { * @param {Object} `options` [Options](#options) to pass to gray-matter. * @return {Object} Returns [an object](#returned-object) with `data` and `content` */ - export function read>( + export function read, MatterShape extends MatterShapeTemplate>( fp: string, options?: GrayMatterOption - ): matter.GrayMatterFile + ): matter.GrayMatterFile /** * Returns true if the given `string` has front matter.