Contextual typing by tuple rest elements
This commit is contained in:
parent
3cc3b49030
commit
d7443f04fd
1 changed files with 13 additions and 2 deletions
|
@ -15531,8 +15531,19 @@ namespace ts {
|
|||
|
||||
function getTypeOfPropertyOfContextualType(type: Type, name: __String) {
|
||||
return mapType(type, t => {
|
||||
const prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined;
|
||||
return prop ? getTypeOfSymbol(prop) : undefined;
|
||||
if (t.flags & TypeFlags.StructuredType) {
|
||||
const prop = getPropertyOfType(t, name);
|
||||
if (prop) {
|
||||
return getTypeOfSymbol(prop);
|
||||
}
|
||||
if (isTupleType(t)) {
|
||||
const restType = getRestTypeOfTupleType(t);
|
||||
if (restType && isNumericLiteralName(name) && +name >= 0) {
|
||||
return restType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}, /*noReductions*/ true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue