Skip to content

Commit 84c83da

Browse files
Revert #37106 (#38172)
1 parent b1d464d commit 84c83da

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20555,7 +20555,7 @@ namespace ts {
2055520555
}
2055620556

2055720557
function narrowByInKeyword(type: Type, literal: LiteralExpression, assumeTrue: boolean) {
20558-
if (type.flags & (TypeFlags.Union | TypeFlags.Object | TypeFlags.Intersection) || isThisTypeParameter(type)) {
20558+
if (type.flags & (TypeFlags.Union | TypeFlags.Object) || isThisTypeParameter(type)) {
2055920559
const propName = escapeLeadingUnderscores(literal.text);
2056020560
return filterType(type, t => isTypePresencePossible(t, propName, assumeTrue));
2056120561
}

tests/baselines/reference/inKeywordTypeguard.errors.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ tests/cases/compiler/inKeywordTypeguard.ts(74,32): error TS2339: Property 'a' do
1919
tests/cases/compiler/inKeywordTypeguard.ts(82,39): error TS2339: Property 'b' does not exist on type 'A'.
2020
tests/cases/compiler/inKeywordTypeguard.ts(84,39): error TS2339: Property 'a' does not exist on type 'B'.
2121
tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' does not exist on type 'never'.
22+
tests/cases/compiler/inKeywordTypeguard.ts(103,13): error TS2322: Type '{ a: string; } & { b: string; }' is not assignable to type 'never'.
2223

2324

24-
==== tests/cases/compiler/inKeywordTypeguard.ts (17 errors) ====
25+
==== tests/cases/compiler/inKeywordTypeguard.ts (18 errors) ====
2526
class A { a: string; }
2627
class B { b: string; }
2728

@@ -163,6 +164,8 @@ tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' do
163164
let s: string = x.a;
164165
} else {
165166
let n: never = x;
167+
~
168+
!!! error TS2322: Type '{ a: string; } & { b: string; }' is not assignable to type 'never'.
166169
}
167170
}
168171

tests/baselines/reference/inKeywordTypeguard.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function positiveIntersectionTest(x: { a: string } & { b: string }) {
318318
} else {
319319
let n: never = x;
320320
>n : never
321-
>x : never
321+
>x : { a: string; } & { b: string; }
322322
}
323323
}
324324

0 commit comments

Comments
 (0)