From 0c9e5f3d403b4e8bfc616c9cef3503caf21e1bcf Mon Sep 17 00:00:00 2001 From: Takuma Suzuki Date: Thu, 18 Oct 2018 01:04:04 +0900 Subject: [PATCH] Make return value of LinkifyIt.match nullable (#29810) --- types/linkify-it/index.d.ts | 2 +- types/linkify-it/linkify-it-tests.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/linkify-it/index.d.ts b/types/linkify-it/index.d.ts index e3696e09c4..ae12f98524 100644 --- a/types/linkify-it/index.d.ts +++ b/types/linkify-it/index.d.ts @@ -45,7 +45,7 @@ declare namespace LinkifyIt { interface LinkifyIt { add(schema: string, rule: Rule): LinkifyIt; - match(text: string): Match[]; + match(text: string): Match[] | null; normalize(raw: string): string; pretest(text: string): boolean; set(options: Options): LinkifyIt; diff --git a/types/linkify-it/linkify-it-tests.ts b/types/linkify-it/linkify-it-tests.ts index 1768bd5efb..6186fe2b7f 100644 --- a/types/linkify-it/linkify-it-tests.ts +++ b/types/linkify-it/linkify-it-tests.ts @@ -30,7 +30,9 @@ linkifier const matches = linkifier.match( "https://github.com/DefinitelyTyped/DefinitelyTyped/" ); -matches.forEach(({ index, lastIndex, raw, schema, text, url }) => {}); +if (matches !== null) { + matches.forEach(({ index, lastIndex, raw, schema, text, url }) => {}); +} // complex rule linkifier.add("@", {