Skip to content

Commit 71a2b47

Browse files
committed
Update test
1 parent 68a6c0e commit 71a2b47

File tree

5 files changed

+54
-47
lines changed

5 files changed

+54
-47
lines changed

tests/baselines/reference/templateLiteralTypes1.errors.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tests/cases/conformance/types/literal/templateLiteralTypes1.ts(165,15): error TS
66
tests/cases/conformance/types/literal/templateLiteralTypes1.ts(197,16): error TS2590: Expression produces a union type that is too complex to represent.
77
tests/cases/conformance/types/literal/templateLiteralTypes1.ts(201,16): error TS2590: Expression produces a union type that is too complex to represent.
88
tests/cases/conformance/types/literal/templateLiteralTypes1.ts(205,16): error TS2590: Expression produces a union type that is too complex to represent.
9-
tests/cases/conformance/types/literal/templateLiteralTypes1.ts(251,7): error TS2590: Expression produces a union type that is too complex to represent.
9+
tests/cases/conformance/types/literal/templateLiteralTypes1.ts(252,7): error TS2590: Expression produces a union type that is too complex to represent.
1010

1111

1212
==== tests/cases/conformance/types/literal/templateLiteralTypes1.ts (7 errors) ====
@@ -242,6 +242,7 @@ tests/cases/conformance/types/literal/templateLiteralTypes1.ts(251,7): error TS2
242242
// Repro from #40970
243243

244244
type PathKeys<T> =
245+
unknown extends T ? never :
245246
T extends readonly any[] ? Extract<keyof T, `${number}`> | SubKeys<T, Extract<keyof T, `${number}`>> :
246247
T extends object ? Extract<keyof T, string> | SubKeys<T, Extract<keyof T, string>> :
247248
never;

tests/baselines/reference/templateLiteralTypes1.js

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ type BB = AA<-2, -2>;
217217
// Repro from #40970
218218

219219
type PathKeys<T> =
220+
unknown extends T ? never :
220221
T extends readonly any[] ? Extract<keyof T, `${number}`> | SubKeys<T, Extract<keyof T, `${number}`>> :
221222
T extends object ? Extract<keyof T, string> | SubKeys<T, Extract<keyof T, string>> :
222223
never;

tests/baselines/reference/templateLiteralTypes1.symbols

+49-46
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,14 @@ type PathKeys<T> =
878878
>PathKeys : Symbol(PathKeys, Decl(templateLiteralTypes1.ts, 213, 21))
879879
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
880880

881+
unknown extends T ? never :
882+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
883+
881884
T extends readonly any[] ? Extract<keyof T, `${number}`> | SubKeys<T, Extract<keyof T, `${number}`>> :
882885
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
883886
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
884887
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
885-
>SubKeys : Symbol(SubKeys, Decl(templateLiteralTypes1.ts, 220, 10))
888+
>SubKeys : Symbol(SubKeys, Decl(templateLiteralTypes1.ts, 221, 10))
886889
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
887890
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
888891
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
@@ -891,100 +894,100 @@ type PathKeys<T> =
891894
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
892895
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
893896
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
894-
>SubKeys : Symbol(SubKeys, Decl(templateLiteralTypes1.ts, 220, 10))
897+
>SubKeys : Symbol(SubKeys, Decl(templateLiteralTypes1.ts, 221, 10))
895898
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
896899
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
897900
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 217, 14))
898901

899902
never;
900903

901904
type SubKeys<T, K extends string> = K extends keyof T ? `${K}.${PathKeys<T[K]>}` : never;
902-
>SubKeys : Symbol(SubKeys, Decl(templateLiteralTypes1.ts, 220, 10))
903-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 222, 13))
904-
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 222, 15))
905-
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 222, 15))
906-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 222, 13))
907-
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 222, 15))
905+
>SubKeys : Symbol(SubKeys, Decl(templateLiteralTypes1.ts, 221, 10))
906+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 223, 13))
907+
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 223, 15))
908+
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 223, 15))
909+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 223, 13))
910+
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 223, 15))
908911
>PathKeys : Symbol(PathKeys, Decl(templateLiteralTypes1.ts, 213, 21))
909-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 222, 13))
910-
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 222, 15))
912+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 223, 13))
913+
>K : Symbol(K, Decl(templateLiteralTypes1.ts, 223, 15))
911914

912915
declare function getProp2<T, P extends PathKeys<T>>(obj: T, path: P): PropType<T, P>;
913-
>getProp2 : Symbol(getProp2, Decl(templateLiteralTypes1.ts, 222, 89))
914-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 224, 26))
915-
>P : Symbol(P, Decl(templateLiteralTypes1.ts, 224, 28))
916+
>getProp2 : Symbol(getProp2, Decl(templateLiteralTypes1.ts, 223, 89))
917+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 225, 26))
918+
>P : Symbol(P, Decl(templateLiteralTypes1.ts, 225, 28))
916919
>PathKeys : Symbol(PathKeys, Decl(templateLiteralTypes1.ts, 213, 21))
917-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 224, 26))
918-
>obj : Symbol(obj, Decl(templateLiteralTypes1.ts, 224, 52))
919-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 224, 26))
920-
>path : Symbol(path, Decl(templateLiteralTypes1.ts, 224, 59))
921-
>P : Symbol(P, Decl(templateLiteralTypes1.ts, 224, 28))
920+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 225, 26))
921+
>obj : Symbol(obj, Decl(templateLiteralTypes1.ts, 225, 52))
922+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 225, 26))
923+
>path : Symbol(path, Decl(templateLiteralTypes1.ts, 225, 59))
924+
>P : Symbol(P, Decl(templateLiteralTypes1.ts, 225, 28))
922925
>PropType : Symbol(PropType, Decl(templateLiteralTypes1.ts, 138, 69))
923-
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 224, 26))
924-
>P : Symbol(P, Decl(templateLiteralTypes1.ts, 224, 28))
926+
>T : Symbol(T, Decl(templateLiteralTypes1.ts, 225, 26))
927+
>P : Symbol(P, Decl(templateLiteralTypes1.ts, 225, 28))
925928

926929
const obj2 = {
927-
>obj2 : Symbol(obj2, Decl(templateLiteralTypes1.ts, 226, 5))
930+
>obj2 : Symbol(obj2, Decl(templateLiteralTypes1.ts, 227, 5))
928931

929932
name: 'John',
930-
>name : Symbol(name, Decl(templateLiteralTypes1.ts, 226, 14))
933+
>name : Symbol(name, Decl(templateLiteralTypes1.ts, 227, 14))
931934

932935
age: 42,
933-
>age : Symbol(age, Decl(templateLiteralTypes1.ts, 227, 17))
936+
>age : Symbol(age, Decl(templateLiteralTypes1.ts, 228, 17))
934937

935938
cars: [
936-
>cars : Symbol(cars, Decl(templateLiteralTypes1.ts, 228, 12))
939+
>cars : Symbol(cars, Decl(templateLiteralTypes1.ts, 229, 12))
937940

938941
{ make: 'Ford', age: 10 },
939-
>make : Symbol(make, Decl(templateLiteralTypes1.ts, 230, 9))
940-
>age : Symbol(age, Decl(templateLiteralTypes1.ts, 230, 23))
942+
>make : Symbol(make, Decl(templateLiteralTypes1.ts, 231, 9))
943+
>age : Symbol(age, Decl(templateLiteralTypes1.ts, 231, 23))
941944

942945
{ make: 'Trabant', age: 35 }
943-
>make : Symbol(make, Decl(templateLiteralTypes1.ts, 231, 9))
944-
>age : Symbol(age, Decl(templateLiteralTypes1.ts, 231, 26))
946+
>make : Symbol(make, Decl(templateLiteralTypes1.ts, 232, 9))
947+
>age : Symbol(age, Decl(templateLiteralTypes1.ts, 232, 26))
945948

946949
]
947950
} as const;
948951
>const : Symbol(const)
949952

950953
let make = getProp2(obj2, 'cars.1.make'); // 'Trabant'
951-
>make : Symbol(make, Decl(templateLiteralTypes1.ts, 235, 3))
952-
>getProp2 : Symbol(getProp2, Decl(templateLiteralTypes1.ts, 222, 89))
953-
>obj2 : Symbol(obj2, Decl(templateLiteralTypes1.ts, 226, 5))
954+
>make : Symbol(make, Decl(templateLiteralTypes1.ts, 236, 3))
955+
>getProp2 : Symbol(getProp2, Decl(templateLiteralTypes1.ts, 223, 89))
956+
>obj2 : Symbol(obj2, Decl(templateLiteralTypes1.ts, 227, 5))
954957

955958
// Repro from #46480
956959

957960
export type Spacing =
958-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
961+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
959962

960963
| `0`
961964
| `${number}px`
962965
| `${number}rem`
963966
| `s${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20}`;
964967

965968
const spacing: Spacing = "s12"
966-
>spacing : Symbol(spacing, Decl(templateLiteralTypes1.ts, 245, 5))
967-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
969+
>spacing : Symbol(spacing, Decl(templateLiteralTypes1.ts, 246, 5))
970+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
968971

969972
export type SpacingShorthand =
970-
>SpacingShorthand : Symbol(SpacingShorthand, Decl(templateLiteralTypes1.ts, 245, 30))
973+
>SpacingShorthand : Symbol(SpacingShorthand, Decl(templateLiteralTypes1.ts, 246, 30))
971974

972975
| `${Spacing} ${Spacing}`
973-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
974-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
976+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
977+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
975978

976979
| `${Spacing} ${Spacing} ${Spacing}`
977-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
978-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
979-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
980+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
981+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
982+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
980983

981984
| `${Spacing} ${Spacing} ${Spacing} ${Spacing}`;
982-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
983-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
984-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
985-
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 235, 41))
985+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
986+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
987+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
988+
>Spacing : Symbol(Spacing, Decl(templateLiteralTypes1.ts, 236, 41))
986989

987990
const test1: SpacingShorthand = "0 0 0";
988-
>test1 : Symbol(test1, Decl(templateLiteralTypes1.ts, 252, 5))
989-
>SpacingShorthand : Symbol(SpacingShorthand, Decl(templateLiteralTypes1.ts, 245, 30))
991+
>test1 : Symbol(test1, Decl(templateLiteralTypes1.ts, 253, 5))
992+
>SpacingShorthand : Symbol(SpacingShorthand, Decl(templateLiteralTypes1.ts, 246, 30))
990993

tests/baselines/reference/templateLiteralTypes1.types

+1
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ type BB = AA<-2, -2>;
541541
type PathKeys<T> =
542542
>PathKeys : PathKeys<T>
543543

544+
unknown extends T ? never :
544545
T extends readonly any[] ? Extract<keyof T, `${number}`> | SubKeys<T, Extract<keyof T, `${number}`>> :
545546
T extends object ? Extract<keyof T, string> | SubKeys<T, Extract<keyof T, string>> :
546547
never;

tests/cases/conformance/types/literal/templateLiteralTypes1.ts

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ type BB = AA<-2, -2>;
219219
// Repro from #40970
220220

221221
type PathKeys<T> =
222+
unknown extends T ? never :
222223
T extends readonly any[] ? Extract<keyof T, `${number}`> | SubKeys<T, Extract<keyof T, `${number}`>> :
223224
T extends object ? Extract<keyof T, string> | SubKeys<T, Extract<keyof T, string>> :
224225
never;

0 commit comments

Comments
 (0)