Skip to content

Negative numbers are not treated like type literals #31461

@ghost

Description

TypeScript Version: 3.4.5

Search Terms: negative keys key

Code

type Value = {
    [-1]: any;
};

Expected behavior:
No compiler errors.

Actual behavior:
Compiler error: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol'

Playground Link: playground link

Related Issues: #31460

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions