From c6e84b9c654be1e8a3acdb405f7e9fe4753a95eb Mon Sep 17 00:00:00 2001 From: Lemuel Flores Date: Fri, 16 Jun 2023 06:21:34 +0800 Subject: [PATCH] fix: update Typescript types (#643) --- packages/metascraper/src/index.d.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/metascraper/src/index.d.ts b/packages/metascraper/src/index.d.ts index 1c8564fd1..06d23e607 100644 --- a/packages/metascraper/src/index.d.ts +++ b/packages/metascraper/src/index.d.ts @@ -1,13 +1,15 @@ declare module 'metascraper' { - export default function MetaParser(rules: Rule[]): Scraper; + export default function MetaParser(rules: RuleSet[]): Scraper; type Scraper = (options: ScrapOptions) => Promise; + interface ScrapOptions { url: string; html?: string; - rules?: Rule[]; + rules?: RuleSet[]; validateUrl?: boolean; } + interface Metadata { author: string; date: string; @@ -17,17 +19,21 @@ declare module 'metascraper' { title: string; url: string; } + type RuleSet = { [C in keyof Metadata]?: Array; - }; + } & { + test?: (options: CheckOptions) => boolean; + } + type Check = (options: CheckOptions) => string | null | undefined; + interface CheckOptions { - htmlDom: typeof import('cheerio'); + htmlDom: import('cheerio').CheerioAPI; url: string } - type Rule = () => RuleSet; } declare module 'metascraper-*' { - export default function rules(): import('metascraper').Rule; + export default function rules(): import('metascraper').RuleSet; }