Skip to content
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

Fixed an issue with contextual type for intersection properties (take 2) #52095

Merged
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f6074e8
Revert "Revert "Fixed an issue with contextual type for intersection …
Andarist Jan 2, 2023
5b9a5dd
Add failing test cases related to RTK
Andarist Jan 2, 2023
bafe4fb
Treat properties of non-generic mapped types as concrete-like
Andarist Jan 4, 2023
6bb681e
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Jan 17, 2023
59414ae
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Mar 22, 2023
19ab1c5
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist May 22, 2023
3ab5773
always concat indexed mapped type substitutions with either types fro…
Andarist May 22, 2023
48faaa3
tweak code
Andarist May 22, 2023
937a0ea
rename variable
Andarist May 22, 2023
5861cc0
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Jun 13, 2023
b9a9285
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Jul 25, 2023
6d24ca8
Add an extra test case related to JSX
Andarist Jul 25, 2023
ea31c96
expand the JSX test
Andarist Jul 25, 2023
f9744e8
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Dec 12, 2023
2fe75f1
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Mar 13, 2024
04bfab1
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Jul 30, 2024
1f9c4ea
add test case for intersected reverse mapped types
Andarist Jul 30, 2024
52effa5
add an extra test case
Andarist Jul 30, 2024
7211b09
specialcase negated-like conditional types
Andarist Jul 31, 2024
0b89c0f
add extra test case
Andarist Aug 1, 2024
7e90ef7
just intersect all of them but filter out anys
Andarist Aug 2, 2024
49bfb73
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Aug 2, 2024
01c20d4
go back to retrieving constituents separately
Andarist Aug 3, 2024
b0012cf
add an extra test case
Andarist Aug 3, 2024
a1c7ba1
add extra test cases
Andarist Aug 3, 2024
e3f9169
return `unknown` when no consistuent property types are found for int…
Andarist Aug 3, 2024
8645b94
small pr feedback
Andarist Aug 5, 2024
dac6f70
tighten up the check in `isExcludedMappedPropertyName`
Andarist Aug 6, 2024
adee09f
address PR feedback
Andarist Aug 6, 2024
e9502f9
fixed typo
Andarist Aug 7, 2024
f96d66e
Merge remote-tracking branch 'origin/main' into fix/contextual-inters…
Andarist Aug 19, 2024
c0e99ae
add extra test cases
Andarist Aug 19, 2024
f218b97
handle filtering mapped types as types that might exclude properties
Andarist Aug 19, 2024
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
5 changes: 4 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31579,7 +31579,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {

function isExcludedMappedPropertyName(constraint: Type, propertyNameType: Type): boolean {
Andarist marked this conversation as resolved.
Show resolved Hide resolved
if (constraint.flags & TypeFlags.Conditional) {
return !!(getReducedType(getTrueTypeFromConditionalType(constraint as ConditionalType)).flags & TypeFlags.Never) && isTypeAssignableTo(propertyNameType, (constraint as ConditionalType).extendsType);
const type = constraint as ConditionalType;
Andarist marked this conversation as resolved.
Show resolved Hide resolved
return !!(getReducedType(getTrueTypeFromConditionalType(type)).flags & TypeFlags.Never) &&
isTypeAssignableTo(getFalseTypeFromConditionalType(type), type.checkType) &&
Andarist marked this conversation as resolved.
Show resolved Hide resolved
isTypeAssignableTo(propertyNameType, type.extendsType);
}
if (constraint.flags & TypeFlags.Intersection) {
return some((constraint as IntersectionType).types, t => isExcludedMappedPropertyName(t, propertyNameType));
Expand Down