Update types for ansi-regex 4.0 (#31568)

This commit is contained in:
Florian Keller
2018-12-21 00:41:28 +01:00
committed by Nathan Shively-Sanders
parent f680ffc4f0
commit 90df1ee381
2 changed files with 15 additions and 3 deletions

View File

@@ -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']

View File

@@ -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 <https://github.com/mvachhar>
// Florian Keller <https://github.com/ffflorian>
// 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;