Skip to content

Commit 9302319

Browse files
committed
fix union type as named group
1 parent 6b2dd33 commit 9302319

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type NamedGroups = undefined | { [key: string]: string };
1212
export type TypedRegExpMatchArray<TGroups extends Groups = Groups, TNamedGroups extends NamedGroups = NamedGroups, TInputString extends string = string> = {
1313
index?: number;
1414
input?: TInputString;
15-
groups: TNamedGroups extends undefined ? never : TNamedGroups;
15+
groups: TNamedGroups;
1616
} & ( [string,...TGroups] & IntersectedArray<string,TypedRegExpMatchArray<TGroups,TNamedGroups,TInputString>> );
1717

1818
export type TypedRegExpExecArray<TGroups extends Groups = Groups, TNamedGroups extends NamedGroups = NamedGroups, TInputString extends string = string> = TypedRegExpMatchArray<TGroups,TNamedGroups,TInputString> & {

tests/tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ if (exec) {
5757
t(exec.index)<number>();
5858
t(exec.input)<"exec string">();
5959
t( exec.sort(() => 0) )<typeof exec>();
60-
t(exec.groups)<never>();
60+
t(exec.groups)<undefined>();
6161
} else {
6262
t(exec)<null>();
6363
}
6464

6565
declare const match2: TypedRegExpMatchArray<[],undefined|{some?:"test group",other?:"more"}>;
6666

67-
t(match2.groups)<{some?:"test group",other?:"more"}|never>(); // TODO fix never is ignored
67+
t(match2.groups)<{some?:"test group",other?:"more"}|undefined>(); // TODO fix never is ignored
6868
if (match2.groups) {
6969
t(match2.groups)<{some?:"test group",other?:"more"}>();
7070
} else {
71-
t(match2.groups)<never>();
71+
t(match2.groups)<undefined>();
7272
}

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"noUncheckedIndexedAccess": true,
1010
"noUnusedLocals": true,
1111
"noUnusedParameters": true,
12-
"exactOptionalPropertyTypes": true,
1312
"moduleResolution": "node"
1413
}
1514
}

0 commit comments

Comments
 (0)