From 29847ee4ab34ecafedcf363074e451e0a24e36cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Jagie=C5=82=C5=82o?= Date: Fri, 14 Jul 2017 21:17:14 +0200 Subject: [PATCH] Fix types for `XRegExp union` function to accept `(string | RegExp)[]` --- types/xregexp/index.d.ts | 4 ++-- types/xregexp/xregexp-tests.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/types/xregexp/index.d.ts b/types/xregexp/index.d.ts index 3974682fa0..35cd7cf970 100644 --- a/types/xregexp/index.d.ts +++ b/types/xregexp/index.d.ts @@ -84,7 +84,7 @@ declare namespace OuterXRegExp { function uninstall(options: Object): void; function uninstall(options: string): void; - function union(patterns: string[] | RegExp[], flags?: string): RegExp; + function union(patterns: (string | RegExp)[], flags?: string): RegExp; var version: string; // end API definitions @@ -127,7 +127,7 @@ declare namespace OuterXRegExp { function uninstall(options: Object): void; function uninstall(options: string): void; - function union(patterns: string[] | RegExp[], flags?: string): RegExp; + function union(patterns: (string | RegExp)[], flags?: string): RegExp; var version: string; // end API definitions } diff --git a/types/xregexp/xregexp-tests.ts b/types/xregexp/xregexp-tests.ts index 543ceb7227..1dc60bce27 100644 --- a/types/xregexp/xregexp-tests.ts +++ b/types/xregexp/xregexp-tests.ts @@ -8,6 +8,7 @@ import TokenOpts = X.TokenOpts; var exp: RegExp; var expArr: RegExp[]; var expArrArr: RegExp[][]; +var strOrExpArr: (string | RegExp)[]; var chain: RegExp[]; var groupChain: { regex: RegExp; backref: string }[]; var groupChain1: { regex: RegExp; backref: number }[]; @@ -147,5 +148,7 @@ regex = XRegExp.union(strArr, flags); regex = XRegExp.union(strArr); regex = XRegExp.union(expArr, flags); regex = XRegExp.union(expArr); +regex = XRegExp.union(strOrExpArr, flags); +regex = XRegExp.union(strOrExpArr); // -- -- -- -- -- -- -- -- -- -- -- -- --