Skip to content

Commit

Permalink
accept baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl committed Apr 9, 2020
1 parent 487dff7 commit 879f69e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20315,7 +20315,7 @@ namespace ts {
return resultType;
}
return narrowTypeByInKeywordWithExistedPropName(type, propName);
}
}
return type;
}

Expand Down
12 changes: 8 additions & 4 deletions tests/baselines/reference/inKeywordTypeguard.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ tests/cases/compiler/inKeywordTypeguard.ts(16,11): error TS2339: Property 'a' do
tests/cases/compiler/inKeywordTypeguard.ts(27,11): error TS2339: Property 'b' does not exist on type 'AWithOptionalProp | BWithOptionalProp'.
Property 'b' does not exist on type 'AWithOptionalProp'.
tests/cases/compiler/inKeywordTypeguard.ts(42,11): error TS2339: Property 'b' does not exist on type 'AWithMethod'.
tests/cases/compiler/inKeywordTypeguard.ts(49,11): error TS2339: Property 'a' does not exist on type 'never'.
tests/cases/compiler/inKeywordTypeguard.ts(50,11): error TS2339: Property 'b' does not exist on type 'never'.
tests/cases/compiler/inKeywordTypeguard.ts(49,11): error TS2339: Property 'a' does not exist on type '(AWithMethod & { c: unknown; }) | (BWithMethod & { c: unknown; })'.
Property 'a' does not exist on type 'BWithMethod & { c: unknown; }'.
tests/cases/compiler/inKeywordTypeguard.ts(50,11): error TS2339: Property 'b' does not exist on type '(AWithMethod & { c: unknown; }) | (BWithMethod & { c: unknown; })'.
Property 'b' does not exist on type 'AWithMethod & { c: unknown; }'.
tests/cases/compiler/inKeywordTypeguard.ts(52,11): error TS2339: Property 'a' does not exist on type 'AWithMethod | BWithMethod'.
Property 'a' does not exist on type 'BWithMethod'.
tests/cases/compiler/inKeywordTypeguard.ts(53,11): error TS2339: Property 'b' does not exist on type 'AWithMethod | BWithMethod'.
Expand Down Expand Up @@ -85,10 +87,12 @@ tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' do
if ("c" in x) {
x.a();
~
!!! error TS2339: Property 'a' does not exist on type 'never'.
!!! error TS2339: Property 'a' does not exist on type '(AWithMethod & { c: unknown; }) | (BWithMethod & { c: unknown; })'.
!!! error TS2339: Property 'a' does not exist on type 'BWithMethod & { c: unknown; }'.
x.b();
~
!!! error TS2339: Property 'b' does not exist on type 'never'.
!!! error TS2339: Property 'b' does not exist on type '(AWithMethod & { c: unknown; }) | (BWithMethod & { c: unknown; })'.
!!! error TS2339: Property 'b' does not exist on type 'AWithMethod & { c: unknown; }'.
} else {
x.a();
~
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/inKeywordTypeguard.types
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ function negativeTestClassesWithMemberMissingInBothClasses(x: AWithMethod | BWit
x.a();
>x.a() : any
>x.a : any
>x : never
>x : (AWithMethod & { c: unknown; }) | (BWithMethod & { c: unknown; })
>a : any

x.b();
>x.b() : any
>x.b : any
>x : never
>x : (AWithMethod & { c: unknown; }) | (BWithMethod & { c: unknown; })
>b : any

} else {
Expand Down

0 comments on commit 879f69e

Please sign in to comment.