We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3cc3b49 commit d7443f0Copy full SHA for d7443f0
1 file changed
src/compiler/checker.ts
@@ -15531,8 +15531,19 @@ namespace ts {
15531
15532
function getTypeOfPropertyOfContextualType(type: Type, name: __String) {
15533
return mapType(type, t => {
15534
- const prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined;
15535
- return prop ? getTypeOfSymbol(prop) : undefined;
+ if (t.flags & TypeFlags.StructuredType) {
+ const prop = getPropertyOfType(t, name);
15536
+ if (prop) {
15537
+ return getTypeOfSymbol(prop);
15538
+ }
15539
+ if (isTupleType(t)) {
15540
+ const restType = getRestTypeOfTupleType(t);
15541
+ if (restType && isNumericLiteralName(name) && +name >= 0) {
15542
+ return restType;
15543
15544
15545
15546
+ return undefined;
15547
}, /*noReductions*/ true);
15548
}
15549
0 commit comments