fix: permit string/number literal in union type

This commit is contained in:
Troy Tae 2019-09-18 16:19:18 +09:00
parent 350e305b0c
commit a5cda4633b

View File

@ -32797,7 +32797,7 @@ namespace ts {
typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType));
}
if (type.flags & TypeFlags.Union && allTypesAssignableToKind(type, TypeFlags.StringLiteral, /*strict*/ true)) {
if (type.flags & TypeFlags.Union && allTypesAssignableToKind(type, TypeFlags.StringOrNumberLiteral, /*strict*/ true)) {
return grammarErrorOnNode(parameter.name,
Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
}