1- tests/cases/compiler/inKeywordTypeguard.ts(5,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
21tests/cases/compiler/inKeywordTypeguard.ts(6,11): error TS2339: Property 'b' does not exist on type 'A'.
32tests/cases/compiler/inKeywordTypeguard.ts(8,11): error TS2339: Property 'a' does not exist on type 'B'.
4- tests/cases/compiler/inKeywordTypeguard.ts(13,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
53tests/cases/compiler/inKeywordTypeguard.ts(14,11): error TS2339: Property 'b' does not exist on type 'A'.
64tests/cases/compiler/inKeywordTypeguard.ts(16,11): error TS2339: Property 'a' does not exist on type 'B'.
7- tests/cases/compiler/inKeywordTypeguard.ts(24,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
85tests/cases/compiler/inKeywordTypeguard.ts(27,11): error TS2339: Property 'b' does not exist on type 'AWithOptionalProp | BWithOptionalProp'.
96 Property 'b' does not exist on type 'AWithOptionalProp'.
10- tests/cases/compiler/inKeywordTypeguard.ts(40,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
117tests/cases/compiler/inKeywordTypeguard.ts(42,11): error TS2339: Property 'b' does not exist on type 'AWithMethod'.
12- tests/cases/compiler/inKeywordTypeguard.ts(48,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
138tests/cases/compiler/inKeywordTypeguard.ts(49,11): error TS2339: Property 'a' does not exist on type 'never'.
149tests/cases/compiler/inKeywordTypeguard.ts(50,11): error TS2339: Property 'b' does not exist on type 'never'.
1510tests/cases/compiler/inKeywordTypeguard.ts(52,11): error TS2339: Property 'a' does not exist on type 'AWithMethod | BWithMethod'.
1611 Property 'a' does not exist on type 'BWithMethod'.
1712tests/cases/compiler/inKeywordTypeguard.ts(53,11): error TS2339: Property 'b' does not exist on type 'AWithMethod | BWithMethod'.
1813 Property 'b' does not exist on type 'AWithMethod'.
19- tests/cases/compiler/inKeywordTypeguard.ts(61,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
2014tests/cases/compiler/inKeywordTypeguard.ts(62,11): error TS2339: Property 'b' does not exist on type 'A | C | D'.
2115 Property 'b' does not exist on type 'A'.
2216tests/cases/compiler/inKeywordTypeguard.ts(64,11): error TS2339: Property 'a' does not exist on type 'B'.
23- tests/cases/compiler/inKeywordTypeguard.ts(71,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
2417tests/cases/compiler/inKeywordTypeguard.ts(72,32): error TS2339: Property 'b' does not exist on type 'A'.
2518tests/cases/compiler/inKeywordTypeguard.ts(74,32): error TS2339: Property 'a' does not exist on type 'B'.
26- tests/cases/compiler/inKeywordTypeguard.ts(81,20): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
2719tests/cases/compiler/inKeywordTypeguard.ts(82,39): error TS2339: Property 'b' does not exist on type 'A'.
2820tests/cases/compiler/inKeywordTypeguard.ts(84,39): error TS2339: Property 'a' does not exist on type 'B'.
29- tests/cases/compiler/inKeywordTypeguard.ts(92,20): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
3021tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' does not exist on type 'never'.
31- tests/cases/compiler/inKeywordTypeguard.ts(100,16): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
32- tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand side of an 'in' expression must not be a primitive.
3322
3423
35- ==== tests/cases/compiler/inKeywordTypeguard.ts (28 errors) ====
24+ ==== tests/cases/compiler/inKeywordTypeguard.ts (17 errors) ====
3625 class A { a: string; }
3726 class B { b: string; }
3827
3928 function negativeClassesTest(x: A | B) {
4029 if ("a" in x) {
41- ~
42- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
4330 x.b = "1";
4431 ~
4532!!! error TS2339: Property 'b' does not exist on type 'A'.
@@ -52,8 +39,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
5239
5340 function positiveClassesTest(x: A | B) {
5441 if ("a" in x) {
55- ~
56- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
5742 x.b = "1";
5843 ~
5944!!! error TS2339: Property 'b' does not exist on type 'A'.
@@ -69,8 +54,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
6954
7055 function positiveTestClassesWithOptionalProperties(x: AWithOptionalProp | BWithOptionalProp) {
7156 if ("a" in x) {
72- ~
73- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
7457 x.a = "1";
7558 } else {
7659 x.b = "1";
@@ -90,8 +73,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
9073
9174 function negativeTestClassesWithMembers(x: AWithMethod | BWithMethod) {
9275 if ("a" in x) {
93- ~
94- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
9576 x.a();
9677 x.b();
9778 ~
@@ -102,8 +83,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
10283
10384 function negativeTestClassesWithMemberMissingInBothClasses(x: AWithMethod | BWithMethod) {
10485 if ("c" in x) {
105- ~
106- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
10786 x.a();
10887 ~
10988!!! error TS2339: Property 'a' does not exist on type 'never'.
@@ -127,8 +106,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
127106
128107 function negativeMultipleClassesTest(x: A | B | C | D) {
129108 if ("a" in x) {
130- ~
131- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
132109 x.b = "1";
133110 ~
134111!!! error TS2339: Property 'b' does not exist on type 'A | C | D'.
@@ -144,8 +121,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
144121
145122 function negativePropTest(x: ClassWithUnionProp) {
146123 if ("a" in x.prop) {
147- ~~~~~~
148- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
149124 let y: string = x.prop.b;
150125 ~
151126!!! error TS2339: Property 'b' does not exist on type 'A'.
@@ -160,8 +135,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
160135 protected prop: A | B;
161136 inThis() {
162137 if ("a" in this.prop) {
163- ~~~~~~~~~
164- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
165138 let z: number = this.prop.b;
166139 ~
167140!!! error TS2339: Property 'b' does not exist on type 'A'.
@@ -177,8 +150,6 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
177150 a: string;
178151 inThis() {
179152 if ("a" in this) {
180- ~~~~
181- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
182153 } else {
183154 let y = this.a;
184155 ~
@@ -189,17 +160,13 @@ tests/cases/compiler/inKeywordTypeguard.ts(107,27): error TS2361: The right-hand
189160
190161 function positiveIntersectionTest(x: { a: string } & { b: string }) {
191162 if ("a" in x) {
192- ~
193- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
194163 let s: string = x.a;
195164 } else {
196165 let n: never = x;
197166 }
198167 }
199168 function negativeIntersectionTest() {
200169 if ("ontouchstart" in window) {
201- ~~~~~~
202- !!! error TS2361: The right-hand side of an 'in' expression must not be a primitive.
203170 window.ontouchstart
204171 } else {
205172 window.ontouchstart
0 commit comments