From 04339d2df7c3483bcbc44a92a8e4840274aaef02 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 09:05:56 -0700 Subject: [PATCH] Disallow T[K] = T[keyof T] where K extends keyof T `K = keyof T` was already correctly disallowed. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8e34b24cf1b..27b0752f53f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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;