mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Spread types handle nested index [access] types
Nested index [access] types are treated as assignable to themselves only, just like type parameters.
This commit is contained in:
parent
2ae6ecc1a5
commit
f2d739ffcf
@ -6097,10 +6097,10 @@ namespace ts {
|
||||
}
|
||||
const spread = spreadTypes[id] = createType(TypeFlags.Spread) as SpreadType;
|
||||
Debug.assert(!!(left.flags & (TypeFlags.Spread | TypeFlags.Object)), "Left flags: " + left.flags.toString(2));
|
||||
Debug.assert(!!(right.flags & (TypeFlags.TypeParameter | TypeFlags.Intersection | TypeFlags.Object)), "Right flags: " + right.flags.toString(2));
|
||||
Debug.assert(!!(right.flags & (TypeFlags.TypeParameter | TypeFlags.Intersection | TypeFlags.Index | TypeFlags.IndexedAccess | TypeFlags.Object)), "Right flags: " + right.flags.toString(2));
|
||||
spread.symbol = symbol;
|
||||
spread.left = left as SpreadType | ResolvedType;
|
||||
spread.right = right as TypeParameter | IntersectionType | ResolvedType;
|
||||
spread.right = right as TypeParameter | IntersectionType | IndexType | IndexedAccessType | ResolvedType;
|
||||
spread.aliasSymbol = aliasSymbol;
|
||||
spread.aliasTypeArguments = aliasTypeArguments;
|
||||
return spread;
|
||||
@ -7173,7 +7173,8 @@ namespace ts {
|
||||
spreadTypeRelatedTo(source.right.flags & TypeFlags.Object ? source.left as SpreadType : source,
|
||||
target.right.flags & TypeFlags.Object ? target.left as SpreadType : target);
|
||||
}
|
||||
// If both right sides are type parameters or intersections, then they must be identical for the spread types to be related.
|
||||
// If both right sides are type parameters, intersections, index types or indexed access types,
|
||||
// then they must be identical for the spread types to be related.
|
||||
// It also means that the left sides are either spread types or object types.
|
||||
|
||||
// if one left is object and the other is spread, that means the second has another type parameter. which isn't allowed
|
||||
|
||||
@ -2852,7 +2852,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface SpreadType extends Type {
|
||||
left: SpreadType | ResolvedType;
|
||||
right: TypeParameter | IntersectionType | ResolvedType;
|
||||
right: TypeParameter | IntersectionType | IndexType | IndexedAccessType | ResolvedType;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user