@@ -81,15 +81,15 @@ function assertAll(x: Basic) {
81
81
>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 36, 19))
82
82
}
83
83
84
- function assertStringOrNumber(x: string | number) {
84
+ function assertStringOrNumber(x: string | number) {
85
85
>assertStringOrNumber : Symbol(assertStringOrNumber, Decl(narrowingByTypeofInSwitch.ts, 38, 1))
86
86
>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 40, 30))
87
87
88
88
return x;
89
89
>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 40, 30))
90
90
}
91
91
92
- function assertBooleanOrObject(x: boolean | object) {
92
+ function assertBooleanOrObject(x: boolean | object) {
93
93
>assertBooleanOrObject : Symbol(assertBooleanOrObject, Decl(narrowingByTypeofInSwitch.ts, 42, 1))
94
94
>x : Symbol(x, Decl(narrowingByTypeofInSwitch.ts, 44, 31))
95
95
@@ -634,53 +634,39 @@ function unknownNarrowing(x: unknown) {
634
634
}
635
635
}
636
636
637
- function keyofNarrowing<T >(k: keyof T ) {
637
+ function keyofNarrowing<S extends { [K in keyof S]: string } >(k: keyof S ) {
638
638
>keyofNarrowing : Symbol(keyofNarrowing, Decl(narrowingByTypeofInSwitch.ts, 226, 1))
639
- >T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 228, 24))
640
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
641
- >T : Symbol(T, Decl(narrowingByTypeofInSwitch.ts, 228, 24))
642
-
643
- function assertKeyofT(k1: keyof T) { }
644
- >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 40))
639
+ >S : Symbol(S, Decl(narrowingByTypeofInSwitch.ts, 228, 24))
640
+ >K : Symbol(K, Decl(narrowingByTypeofInSwitch.ts, 228, 37))
641
+ >S : Symbol(S, Decl(narrowingByTypeofInSwitch.ts, 228, 24))
642
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62))
643
+ >S : Symbol(S, Decl(narrowingByTypeofInSwitch.ts, 228, 24))
644
+
645
+ function assertKeyofT(k1: keyof S) { }
646
+ >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 75))
645
647
>k1 : Symbol(k1, Decl(narrowingByTypeofInSwitch.ts, 229, 26))
646
- >T : Symbol(T , Decl(narrowingByTypeofInSwitch.ts, 228, 24))
648
+ >S : Symbol(S , Decl(narrowingByTypeofInSwitch.ts, 228, 24))
647
649
648
650
switch (typeof k) {
649
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27 ))
651
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62 ))
650
652
651
653
case 'number': assertNumber(k); assertKeyofT(k); return;
652
654
>assertNumber : Symbol(assertNumber, Decl(narrowingByTypeofInSwitch.ts, 2, 1))
653
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27 ))
654
- >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 40 ))
655
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27 ))
655
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62 ))
656
+ >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 75 ))
657
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62 ))
656
658
657
659
case 'symbol': assertSymbol(k); assertKeyofT(k); return;
658
660
>assertSymbol : Symbol(assertSymbol, Decl(narrowingByTypeofInSwitch.ts, 14, 1))
659
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27 ))
660
- >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 40 ))
661
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27 ))
661
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62 ))
662
+ >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 75 ))
663
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62 ))
662
664
663
665
case 'string': assertString(k); assertKeyofT(k); return;
664
666
>assertString : Symbol(assertString, Decl(narrowingByTypeofInSwitch.ts, 10, 1))
665
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
666
- >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 40))
667
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
668
-
669
- case 'boolean': assertNever(k);
670
- >assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0))
671
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
672
-
673
- case 'function': assertNever(k);
674
- >assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0))
675
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
676
-
677
- case 'object': assertNever(k);
678
- >assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0))
679
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
680
-
681
- case 'undefined': assertNever(k); return;
682
- >assertNever : Symbol(assertNever, Decl(narrowingByTypeofInSwitch.ts, 0, 0))
683
- >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 27))
667
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62))
668
+ >assertKeyofT : Symbol(assertKeyofT, Decl(narrowingByTypeofInSwitch.ts, 228, 75))
669
+ >k : Symbol(k, Decl(narrowingByTypeofInSwitch.ts, 228, 62))
684
670
}
685
671
}
686
672
0 commit comments