@@ -879,3 +879,69 @@ const f = <P extends object>(a: P & {}) => {
879
879
880
880
};
881
881
882
+ // Repro from #53773
883
+
884
+ function test1<T extends any[] | Record<string, any>>(obj: T) {
885
+ >test1 : Symbol(test1, Decl(inKeywordTypeguard.ts, 353, 2))
886
+ >T : Symbol(T, Decl(inKeywordTypeguard.ts, 357, 15))
887
+ >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
888
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 357, 54))
889
+ >T : Symbol(T, Decl(inKeywordTypeguard.ts, 357, 15))
890
+
891
+ if (Array.isArray(obj) || 'length' in obj) {
892
+ >Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
893
+ >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
894
+ >isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
895
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 357, 54))
896
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 357, 54))
897
+
898
+ obj; // T
899
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 357, 54))
900
+ }
901
+ else {
902
+ obj; // T
903
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 357, 54))
904
+ }
905
+ }
906
+
907
+ function test2<T extends any[] | Record<string, any>>(obj: T) {
908
+ >test2 : Symbol(test2, Decl(inKeywordTypeguard.ts, 364, 1))
909
+ >T : Symbol(T, Decl(inKeywordTypeguard.ts, 366, 15))
910
+ >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
911
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 366, 54))
912
+ >T : Symbol(T, Decl(inKeywordTypeguard.ts, 366, 15))
913
+
914
+ if (Array.isArray(obj)) {
915
+ >Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
916
+ >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
917
+ >isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
918
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 366, 54))
919
+
920
+ obj; // T & any[]
921
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 366, 54))
922
+ }
923
+ else {
924
+ obj; // T
925
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 366, 54))
926
+ }
927
+ }
928
+
929
+ function test3<T extends any[] | Record<string, any>>(obj: T) {
930
+ >test3 : Symbol(test3, Decl(inKeywordTypeguard.ts, 373, 1))
931
+ >T : Symbol(T, Decl(inKeywordTypeguard.ts, 375, 15))
932
+ >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
933
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 375, 54))
934
+ >T : Symbol(T, Decl(inKeywordTypeguard.ts, 375, 15))
935
+
936
+ if ('length' in obj) {
937
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 375, 54))
938
+
939
+ obj; // T
940
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 375, 54))
941
+ }
942
+ else {
943
+ obj; // T
944
+ >obj : Symbol(obj, Decl(inKeywordTypeguard.ts, 375, 54))
945
+ }
946
+ }
947
+
0 commit comments