Skip to content

Commit ac0cc8c

Browse files
TypeScript Botahejlsberg
TypeScript Bot
andauthored
Cherry-pick PR #50535 into release-4.8 (#50549)
Component commits: 7bd2a6e Only normalize intersections that include {} 698c3ab Accept new baselines Co-authored-by: Anders Hejlsberg <[email protected]>
1 parent 8b79b2f commit ac0cc8c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18465,7 +18465,7 @@ namespace ts {
1846518465
if (reduced !== type) {
1846618466
return reduced;
1846718467
}
18468-
if (type.flags & TypeFlags.Intersection) {
18468+
if (type.flags & TypeFlags.Intersection && some((type as IntersectionType).types, isEmptyAnonymousObjectType)) {
1846918469
const normalizedTypes = sameMap(type.types, t => getNormalizedType(t, writing));
1847018470
if (normalizedTypes !== type.types) {
1847118471
return getIntersectionType(normalizedTypes);

tests/baselines/reference/conditionalTypes2.errors.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(74,12): error TS2
3232
Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'.
3333
tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract2<T, Foo, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'.
3434
Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'.
35-
Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'.
35+
Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'.
3636

3737

3838
==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (7 errors) ====
@@ -159,7 +159,8 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2
159159
~
160160
!!! error TS2345: Argument of type 'Extract2<T, Foo, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'.
161161
!!! error TS2345: Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'.
162-
!!! error TS2345: Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'.
162+
!!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'.
163+
!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here.
163164
}
164165

165166
// Repros from #22860

0 commit comments

Comments
 (0)