diff --git a/types/ansi-regex/ansi-regex-tests.ts b/types/ansi-regex/ansi-regex-tests.ts index a5787902f0..d4217e9608 100644 --- a/types/ansi-regex/ansi-regex-tests.ts +++ b/types/ansi-regex/ansi-regex-tests.ts @@ -9,5 +9,8 @@ ansiRegex().test('\u001B[4mcake\u001B[0m'); // $ExpectType boolean ansiRegex().test('cake'); // $ExpectType boolean // => false +ansiRegex({onlyFirst: true}).test('cake'); // $ExpectType boolean +// => false + '\u001B[4mcake\u001B[0m'.match(ansiRegex()); // $ExpectType RegExpMatchArray | null // => ['\u001B[4m', '\u001B[0m'] diff --git a/types/ansi-regex/index.d.ts b/types/ansi-regex/index.d.ts index 34890912dc..52979125f7 100644 --- a/types/ansi-regex/index.d.ts +++ b/types/ansi-regex/index.d.ts @@ -1,7 +1,16 @@ -// Type definitions for ansi-regex 3.0 +// Type definitions for ansi-regex 4.0 // Project: https://github.com/chalk/ansi-regex#readme // Definitions by: Manish Vachharajani +// Florian Keller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function r(): RegExp; -export = r; +declare namespace ansiRegex { + interface Options { + /** Match only the first ANSI escape. */ + onlyFirst?: boolean; + } +} + +declare function ansiRegex(options?: ansiRegex.Options): RegExp; + +export = ansiRegex;