Skip to content

Consistently propagate intersectionState in relations #52392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 49 additions & 39 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions tests/baselines/reference/nestedExcessPropertyChecking.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,25 @@ tests/cases/compiler/nestedExcessPropertyChecking.ts(40,9): error TS2559: Type '
!!! related TS6500 tests/cases/compiler/nestedExcessPropertyChecking.ts:35:24: The expected type comes from property 'overrides' which is declared here on type 'VariablesA & VariablesB'
}
};

// Simplified repro from #52252

type T1 = {
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
};

type T2 = {
primary: { __typename?: 'Feature' } & { colors: { light: number } },
};

type Query = T1 & T2;

const response: Query = {
primary: {
colors: {
light: 1,
dark: 3,
},
},
};

29 changes: 29 additions & 0 deletions tests/baselines/reference/nestedExcessPropertyChecking.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
overrides: false // Error
}
};

// Simplified repro from #52252

type T1 = {
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
};

type T2 = {
primary: { __typename?: 'Feature' } & { colors: { light: number } },
};

type Query = T1 & T2;

const response: Query = {
primary: {
colors: {
light: 1,
dark: 3,
},
},
};


//// [nestedExcessPropertyChecking.js]
Expand All @@ -59,3 +80,11 @@ var foo2 = {
overrides: false // Error
}
};
var response = {
primary: {
colors: {
light: 1,
dark: 3,
},
},
};
50 changes: 50 additions & 0 deletions tests/baselines/reference/nestedExcessPropertyChecking.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,53 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
}
};

// Simplified repro from #52252

type T1 = {
>T1 : Symbol(T1, Decl(nestedExcessPropertyChecking.ts, 41, 2))

primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
>primary : Symbol(primary, Decl(nestedExcessPropertyChecking.ts, 45, 11))
>__typename : Symbol(__typename, Decl(nestedExcessPropertyChecking.ts, 46, 14))
>colors : Symbol(colors, Decl(nestedExcessPropertyChecking.ts, 46, 43))
>light : Symbol(light, Decl(nestedExcessPropertyChecking.ts, 46, 53))
>dark : Symbol(dark, Decl(nestedExcessPropertyChecking.ts, 46, 68))

};

type T2 = {
>T2 : Symbol(T2, Decl(nestedExcessPropertyChecking.ts, 47, 2))

primary: { __typename?: 'Feature' } & { colors: { light: number } },
>primary : Symbol(primary, Decl(nestedExcessPropertyChecking.ts, 49, 11))
>__typename : Symbol(__typename, Decl(nestedExcessPropertyChecking.ts, 50, 14))
>colors : Symbol(colors, Decl(nestedExcessPropertyChecking.ts, 50, 43))
>light : Symbol(light, Decl(nestedExcessPropertyChecking.ts, 50, 53))

};

type Query = T1 & T2;
>Query : Symbol(Query, Decl(nestedExcessPropertyChecking.ts, 51, 2))
>T1 : Symbol(T1, Decl(nestedExcessPropertyChecking.ts, 41, 2))
>T2 : Symbol(T2, Decl(nestedExcessPropertyChecking.ts, 47, 2))

const response: Query = {
>response : Symbol(response, Decl(nestedExcessPropertyChecking.ts, 55, 5))
>Query : Symbol(Query, Decl(nestedExcessPropertyChecking.ts, 51, 2))

primary: {
>primary : Symbol(primary, Decl(nestedExcessPropertyChecking.ts, 55, 25))

colors: {
>colors : Symbol(colors, Decl(nestedExcessPropertyChecking.ts, 56, 14))

light: 1,
>light : Symbol(light, Decl(nestedExcessPropertyChecking.ts, 57, 17))

dark: 3,
>dark : Symbol(dark, Decl(nestedExcessPropertyChecking.ts, 58, 21))

},
},
};

52 changes: 52 additions & 0 deletions tests/baselines/reference/nestedExcessPropertyChecking.types
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,55 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
}
};

// Simplified repro from #52252

type T1 = {
>T1 : { primary: { __typename?: 'Feature';} & { colors: { light: number; dark: number; };}; }

primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
>primary : { __typename?: "Feature" | undefined; } & { colors: { light: number; dark: number;}; }
>__typename : "Feature" | undefined
>colors : { light: number; dark: number; }
>light : number
>dark : number

};

type T2 = {
>T2 : { primary: { __typename?: 'Feature';} & { colors: { light: number; };}; }

primary: { __typename?: 'Feature' } & { colors: { light: number } },
>primary : { __typename?: "Feature" | undefined; } & { colors: { light: number;}; }
>__typename : "Feature" | undefined
>colors : { light: number; }
>light : number

};

type Query = T1 & T2;
>Query : T1 & T2

const response: Query = {
>response : Query
>{ primary: { colors: { light: 1, dark: 3, }, },} : { primary: { colors: { light: number; dark: number; }; }; }

primary: {
>primary : { colors: { light: number; dark: number; }; }
>{ colors: { light: 1, dark: 3, }, } : { colors: { light: number; dark: number; }; }

colors: {
>colors : { light: number; dark: number; }
>{ light: 1, dark: 3, } : { light: number; dark: number; }

light: 1,
>light : number
>1 : 1

dark: 3,
>dark : number
>3 : 3

},
},
};

16 changes: 4 additions & 12 deletions tests/baselines/reference/unionThisTypeInFunctions.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts(10,5): error
Type '(this: Real, n: number) => void' is not assignable to type '(this: Fake, n: number) => void'.
The 'this' types of each signature are incompatible.
Type 'Fake' is not assignable to type 'Real'.
Types of property 'method' are incompatible.
Type '(this: Fake, n: number) => void' is not assignable to type '(this: Real, n: number) => void'.
The 'this' types of each signature are incompatible.
Type 'Real' is not assignable to type 'Fake'.
Types of property 'data' are incompatible.
Type 'string' is not assignable to type 'number'.
Types of property 'data' are incompatible.
Type 'number' is not assignable to type 'string'.


==== tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts (1 errors) ====
Expand All @@ -32,11 +28,7 @@ tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts(10,5): error
!!! error TS2684: Type '(this: Real, n: number) => void' is not assignable to type '(this: Fake, n: number) => void'.
!!! error TS2684: The 'this' types of each signature are incompatible.
!!! error TS2684: Type 'Fake' is not assignable to type 'Real'.
!!! error TS2684: Types of property 'method' are incompatible.
!!! error TS2684: Type '(this: Fake, n: number) => void' is not assignable to type '(this: Real, n: number) => void'.
!!! error TS2684: The 'this' types of each signature are incompatible.
!!! error TS2684: Type 'Real' is not assignable to type 'Fake'.
!!! error TS2684: Types of property 'data' are incompatible.
!!! error TS2684: Type 'string' is not assignable to type 'number'.
!!! error TS2684: Types of property 'data' are incompatible.
!!! error TS2684: Type 'number' is not assignable to type 'string'.
}

21 changes: 21 additions & 0 deletions tests/cases/compiler/nestedExcessPropertyChecking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,24 @@ const foo2: Unrelated & { variables: VariablesA & VariablesB } = {
overrides: false // Error
}
};

// Simplified repro from #52252

type T1 = {
primary: { __typename?: 'Feature' } & { colors: { light: number, dark: number } },
};

type T2 = {
primary: { __typename?: 'Feature' } & { colors: { light: number } },
};

type Query = T1 & T2;

const response: Query = {
primary: {
colors: {
light: 1,
dark: 3,
},
},
};