Disallow T[K] = T[keyof T] where K extends keyof T

`K = keyof T` was already correctly disallowed.
This commit is contained in:
Nathan Shively-Sanders
2017-08-28 09:05:56 -07:00
parent 85b0969556
commit 04339d2df7
+1 -1
View File
@@ -5914,7 +5914,7 @@ namespace ts {
const keepTypeParameterForMappedType = baseObjectType && getObjectFlags(baseObjectType) & ObjectFlags.Mapped &&
type.indexType.flags & TypeFlags.TypeParameter;
const baseIndexType = !keepTypeParameterForMappedType && getBaseConstraintOfType(type.indexType);
if (baseObjectType && baseIndexType === stringType && !getIndexInfoOfType(baseObjectType, IndexKind.String)) {
if (baseIndexType === stringType && (!baseObjectType || !getIndexInfoOfType(baseObjectType, IndexKind.String))) {
// getIndexedAccessType returns `any` for X[string] where X doesn't have an index signature.
// to avoid this, return `undefined`.
return undefined;