mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
No excess property error for spread properties (#26798)
That is, properties in an object literal type that came from a spread assignment never cause an excess property error.
This commit is contained in:
committed by
GitHub
parent
cd37e41d3d
commit
b687caf3eb
@@ -11328,7 +11328,7 @@ namespace ts {
|
||||
return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors);
|
||||
}
|
||||
for (const prop of getPropertiesOfObjectType(source)) {
|
||||
if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
// We know *exactly* where things went wrong when comparing the types.
|
||||
// Use this property as the error node as this will be more helpful in
|
||||
@@ -11372,6 +11372,10 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isPropertyFromSpread(prop: Symbol, container: Symbol) {
|
||||
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration;
|
||||
}
|
||||
|
||||
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary {
|
||||
let result = Ternary.True;
|
||||
const sourceTypes = source.types;
|
||||
|
||||
Reference in New Issue
Block a user