-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
No excess properties error in nested intersection type #13813
Comments
I just ran into this bug and it is marked "Needs Investigation", so I thought I would provide some. As far as I can tell (with the caveat that TypeScript is really complicated and I'm a newbie), the problem is with the following code in if (isObjectLiteralType(source) && source.flags & TypeFlags.FreshLiteral) {
const discriminantType = target.flags & TypeFlags.Union ? findMatchingDiscriminantType(source, target as UnionType) : undefined;
if (hasExcessProperties(<FreshObjectLiteralType>source, target, discriminantType, reportErrors)) {
if (reportErrors) {
reportRelationError(headMessage, source, target);
}
return Ternary.False;
}
// Above we check for excess properties with respect to the entire target type. When union
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
if (isUnionOrIntersectionTypeWithoutNullableConstituents(target) && !discriminantType) {
source = getRegularTypeOfObjectLiteral(source);
}
} After the code checks for excess properties only at the top level, |
TypeScript Version: 2.1.5
Code
Expected behavior:
Excess property checking should cause a compiler error for the last example.
Actual behavior:
Last example compiles without error.
The text was updated successfully, but these errors were encountered: