From 486db952df1854362f5a8701de652a75efb2f366 Mon Sep 17 00:00:00 2001 From: Harris Miller Date: Tue, 10 Oct 2023 19:50:49 -0600 Subject: [PATCH] Update: match (#67) --- test/match.test.ts | 8 ++++++++ types/match.d.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/match.test.ts diff --git a/test/match.test.ts b/test/match.test.ts new file mode 100644 index 00000000..a1cbee96 --- /dev/null +++ b/test/match.test.ts @@ -0,0 +1,8 @@ +import { expectType } from 'tsd'; + +import { __, match } from '../es'; + +// not much to test here +expectType(match(/foo/, 'foo')); +expectType(match(/foo/)('foo')); +expectType(match(__, 'foo')(/foo/)); diff --git a/types/match.d.ts b/types/match.d.ts index 30e8f2ae..1d7e23a3 100644 --- a/types/match.d.ts +++ b/types/match.d.ts @@ -1,2 +1,7 @@ -export function match(regexp: RegExp): (str: string) => string[]; -export function match(regexp: RegExp, str: string): string[]; +import { Placeholder } from './util/tools'; + +// ramda used `Array.prototype.match` in its implementation, but never returns undefined +// See: https://github.com/ramda/ramda/blob/v0.29.1/source/match.js#L26 +export function match(regexp: RegExp): (str: string) => RegExpMatchArray; +export function match(__: Placeholder, str: string): (regexp: RegExp) => RegExpMatchArray; +export function match(regexp: RegExp, str: string): RegExpMatchArray;