Skip to content

enum member key should reject bigint #61772

Closed
@JLHwung

Description

@JLHwung

πŸ”Ž Search Terms

enum, bigint, member key

πŸ•— Version & Regression Information

This is the behavior in every version I tried.

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/KYOwrgtgBAolDeAoKKoAYRQLzsQXyA

πŸ’» Code

enum E {
    0n = 0
}

πŸ™ Actual behavior

Transformed to

"use strict";
var E;
(function (E) {
    E[E[0n] = 0] = 0n;
})(E || (E = {}));

without error

πŸ™‚ Expected behavior

It should throw an error "An enum member cannot have a numeric name.", similar to how we handle enum E { 0 = 0 }. Disallowing numeric value 0 but allowing bigInt value 0n as enum member key seems inconsistent.

Additional information about the issue

First reported in babel/babel#17331.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions