Skip to content

Commit 3099385

Browse files
authored
Consistently propagate intersectionState in relations (#52392)
1 parent 9ee3315 commit 3099385

7 files changed

+226
-51
lines changed

src/compiler/checker.ts

+49-39
Large diffs are not rendered by default.

tests/baselines/reference/nestedExcessPropertyChecking.errors.txt

+21
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,25 @@ tests/cases/compiler/nestedExcessPropertyChecking.ts(40,9): error TS2559: Type '
6767
!!! related TS6500 tests/cases/compiler/nestedExcessPropertyChecking.ts:35:24: The expected type comes from property 'overrides' which is declared here on type 'VariablesA & VariablesB'
6868
}
6969
};
70+
71+
// Simplified repro from #52252
72+
73+
type T1 = {
74+
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
75+
};
76+
77+
type T2 = {
78+
primary: { __typename?: 'Feature' } & { colors: { light: number } },
79+
};
80+
81+
type Query = T1 & T2;
82+
83+
const response: Query = {
84+
primary: {
85+
colors: {
86+
light: 1,
87+
dark: 3,
88+
},
89+
},
90+
};
7091

tests/baselines/reference/nestedExcessPropertyChecking.js

+29
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
4141
overrides: false // Error
4242
}
4343
};
44+
45+
// Simplified repro from #52252
46+
47+
type T1 = {
48+
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
49+
};
50+
51+
type T2 = {
52+
primary: { __typename?: 'Feature' } & { colors: { light: number } },
53+
};
54+
55+
type Query = T1 & T2;
56+
57+
const response: Query = {
58+
primary: {
59+
colors: {
60+
light: 1,
61+
dark: 3,
62+
},
63+
},
64+
};
4465

4566

4667
//// [nestedExcessPropertyChecking.js]
@@ -59,3 +80,11 @@ var foo2 = {
5980
overrides: false // Error
6081
}
6182
};
83+
var response = {
84+
primary: {
85+
colors: {
86+
light: 1,
87+
dark: 3,
88+
},
89+
},
90+
};

tests/baselines/reference/nestedExcessPropertyChecking.symbols

+50
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,53 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
113113
}
114114
};
115115

116+
// Simplified repro from #52252
117+
118+
type T1 = {
119+
>T1 : Symbol(T1, Decl(nestedExcessPropertyChecking.ts, 41, 2))
120+
121+
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
122+
>primary : Symbol(primary, Decl(nestedExcessPropertyChecking.ts, 45, 11))
123+
>__typename : Symbol(__typename, Decl(nestedExcessPropertyChecking.ts, 46, 14))
124+
>colors : Symbol(colors, Decl(nestedExcessPropertyChecking.ts, 46, 43))
125+
>light : Symbol(light, Decl(nestedExcessPropertyChecking.ts, 46, 53))
126+
>dark : Symbol(dark, Decl(nestedExcessPropertyChecking.ts, 46, 68))
127+
128+
};
129+
130+
type T2 = {
131+
>T2 : Symbol(T2, Decl(nestedExcessPropertyChecking.ts, 47, 2))
132+
133+
primary: { __typename?: 'Feature' } & { colors: { light: number } },
134+
>primary : Symbol(primary, Decl(nestedExcessPropertyChecking.ts, 49, 11))
135+
>__typename : Symbol(__typename, Decl(nestedExcessPropertyChecking.ts, 50, 14))
136+
>colors : Symbol(colors, Decl(nestedExcessPropertyChecking.ts, 50, 43))
137+
>light : Symbol(light, Decl(nestedExcessPropertyChecking.ts, 50, 53))
138+
139+
};
140+
141+
type Query = T1 & T2;
142+
>Query : Symbol(Query, Decl(nestedExcessPropertyChecking.ts, 51, 2))
143+
>T1 : Symbol(T1, Decl(nestedExcessPropertyChecking.ts, 41, 2))
144+
>T2 : Symbol(T2, Decl(nestedExcessPropertyChecking.ts, 47, 2))
145+
146+
const response: Query = {
147+
>response : Symbol(response, Decl(nestedExcessPropertyChecking.ts, 55, 5))
148+
>Query : Symbol(Query, Decl(nestedExcessPropertyChecking.ts, 51, 2))
149+
150+
primary: {
151+
>primary : Symbol(primary, Decl(nestedExcessPropertyChecking.ts, 55, 25))
152+
153+
colors: {
154+
>colors : Symbol(colors, Decl(nestedExcessPropertyChecking.ts, 56, 14))
155+
156+
light: 1,
157+
>light : Symbol(light, Decl(nestedExcessPropertyChecking.ts, 57, 17))
158+
159+
dark: 3,
160+
>dark : Symbol(dark, Decl(nestedExcessPropertyChecking.ts, 58, 21))
161+
162+
},
163+
},
164+
};
165+

tests/baselines/reference/nestedExcessPropertyChecking.types

+52
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,55 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
106106
}
107107
};
108108

109+
// Simplified repro from #52252
110+
111+
type T1 = {
112+
>T1 : { primary: { __typename?: 'Feature';} & { colors: { light: number; dark: number; };}; }
113+
114+
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
115+
>primary : { __typename?: "Feature" | undefined; } & { colors: { light: number; dark: number;}; }
116+
>__typename : "Feature" | undefined
117+
>colors : { light: number; dark: number; }
118+
>light : number
119+
>dark : number
120+
121+
};
122+
123+
type T2 = {
124+
>T2 : { primary: { __typename?: 'Feature';} & { colors: { light: number; };}; }
125+
126+
primary: { __typename?: 'Feature' } & { colors: { light: number } },
127+
>primary : { __typename?: "Feature" | undefined; } & { colors: { light: number;}; }
128+
>__typename : "Feature" | undefined
129+
>colors : { light: number; }
130+
>light : number
131+
132+
};
133+
134+
type Query = T1 & T2;
135+
>Query : T1 & T2
136+
137+
const response: Query = {
138+
>response : Query
139+
>{ primary: { colors: { light: 1, dark: 3, }, },} : { primary: { colors: { light: number; dark: number; }; }; }
140+
141+
primary: {
142+
>primary : { colors: { light: number; dark: number; }; }
143+
>{ colors: { light: 1, dark: 3, }, } : { colors: { light: number; dark: number; }; }
144+
145+
colors: {
146+
>colors : { light: number; dark: number; }
147+
>{ light: 1, dark: 3, } : { light: number; dark: number; }
148+
149+
light: 1,
150+
>light : number
151+
>1 : 1
152+
153+
dark: 3,
154+
>dark : number
155+
>3 : 3
156+
157+
},
158+
},
159+
};
160+

tests/baselines/reference/unionThisTypeInFunctions.errors.txt

+4-12
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts(10,5): error
55
Type '(this: Real, n: number) => void' is not assignable to type '(this: Fake, n: number) => void'.
66
The 'this' types of each signature are incompatible.
77
Type 'Fake' is not assignable to type 'Real'.
8-
Types of property 'method' are incompatible.
9-
Type '(this: Fake, n: number) => void' is not assignable to type '(this: Real, n: number) => void'.
10-
The 'this' types of each signature are incompatible.
11-
Type 'Real' is not assignable to type 'Fake'.
12-
Types of property 'data' are incompatible.
13-
Type 'string' is not assignable to type 'number'.
8+
Types of property 'data' are incompatible.
9+
Type 'number' is not assignable to type 'string'.
1410

1511

1612
==== tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts (1 errors) ====
@@ -32,11 +28,7 @@ tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts(10,5): error
3228
!!! error TS2684: Type '(this: Real, n: number) => void' is not assignable to type '(this: Fake, n: number) => void'.
3329
!!! error TS2684: The 'this' types of each signature are incompatible.
3430
!!! error TS2684: Type 'Fake' is not assignable to type 'Real'.
35-
!!! error TS2684: Types of property 'method' are incompatible.
36-
!!! error TS2684: Type '(this: Fake, n: number) => void' is not assignable to type '(this: Real, n: number) => void'.
37-
!!! error TS2684: The 'this' types of each signature are incompatible.
38-
!!! error TS2684: Type 'Real' is not assignable to type 'Fake'.
39-
!!! error TS2684: Types of property 'data' are incompatible.
40-
!!! error TS2684: Type 'string' is not assignable to type 'number'.
31+
!!! error TS2684: Types of property 'data' are incompatible.
32+
!!! error TS2684: Type 'number' is not assignable to type 'string'.
4133
}
4234

tests/cases/compiler/nestedExcessPropertyChecking.ts

+21
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,24 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
4242
overrides: false // Error
4343
}
4444
};
45+
46+
// Simplified repro from #52252
47+
48+
type T1 = {
49+
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
50+
};
51+
52+
type T2 = {
53+
primary: { __typename?: 'Feature' } & { colors: { light: number } },
54+
};
55+
56+
type Query = T1 & T2;
57+
58+
const response: Query = {
59+
primary: {
60+
colors: {
61+
light: 1,
62+
dark: 3,
63+
},
64+
},
65+
};

0 commit comments

Comments
 (0)