File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -4666,13 +4666,22 @@ namespace ts {
4666
4666
return type.resolvedApparentType;
4667
4667
}
4668
4668
4669
+ /**
4670
+ * The apparent type of an indexed access T[K] is the type of T's string index signature, if any.
4671
+ */
4672
+ function getApparentTypeOfIndexedAccess(type: IndexedAccessType) {
4673
+ return getIndexTypeOfType(getApparentType(type.objectType), IndexKind.String) || type;
4674
+ }
4675
+
4669
4676
/**
4670
4677
* For a type parameter, return the base constraint of the type parameter. For the string, number,
4671
4678
* boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
4672
4679
* type itself. Note that the apparent type of a union type is the union type itself.
4673
4680
*/
4674
4681
function getApparentType(type: Type): Type {
4675
- const t = type.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>type) : type;
4682
+ const t = type.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>type) :
4683
+ type.flags & TypeFlags.IndexedAccess ? getApparentTypeOfIndexedAccess(<IndexedAccessType>type) :
4684
+ type;
4676
4685
return t.flags & TypeFlags.StringLike ? globalStringType :
4677
4686
t.flags & TypeFlags.NumberLike ? globalNumberType :
4678
4687
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
You can’t perform that action at this time.
0 commit comments