Infer:string literal->keyof creates any props not {}

This commit is contained in:
Nathan Shively-Sanders
2018-01-18 08:44:57 -08:00
parent 3fc8f9d367
commit f0b4018017
5 changed files with 63 additions and 29 deletions

View File

@@ -10965,7 +10965,7 @@ namespace ts {
return type === typeParameter || type.flags & TypeFlags.UnionOrIntersection && forEach((<UnionOrIntersectionType>type).types, t => isTypeParameterAtTopLevel(t, typeParameter));
}
/** Create an object with properties named in the string literal type. Every property has type `{}` */
/** Create an object with properties named in the string literal type. Every property has type `any` */
function createEmptyObjectTypeFromStringLiteral(type: Type) {
const members = createSymbolTable();
forEachType(type, t => {
@@ -10974,7 +10974,7 @@ namespace ts {
}
const name = escapeLeadingUnderscores((t as StringLiteralType).value);
const literalProp = createSymbol(SymbolFlags.Property, name);
literalProp.type = emptyObjectType;
literalProp.type = anyType;
if (t.symbol) {
literalProp.declarations = t.symbol.declarations;
literalProp.valueDeclaration = t.symbol.valueDeclaration;