Skip to content

Commit a5cda46

Browse files
author
Troy Tae
committed
fix: permit string/number literal in union type
1 parent 350e305 commit a5cda46

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32797,7 +32797,7 @@ namespace ts {
3279732797
typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType));
3279832798
}
3279932799

32800-
if (type.flags & TypeFlags.Union && allTypesAssignableToKind(type, TypeFlags.StringLiteral, /*strict*/ true)) {
32800+
if (type.flags & TypeFlags.Union && allTypesAssignableToKind(type, TypeFlags.StringOrNumberLiteral, /*strict*/ true)) {
3280132801
return grammarErrorOnNode(parameter.name,
3280232802
Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
3280332803
}

0 commit comments

Comments
 (0)