Skip to content

Parser error with bigint literal object keys and class properties #50863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
almeidx opened this issue Sep 20, 2022 · 3 comments
Closed

Parser error with bigint literal object keys and class properties #50863

almeidx opened this issue Sep 20, 2022 · 3 comments

Comments

@almeidx
Copy link

almeidx commented Sep 20, 2022

Bug Report

The TypeScript compiler does not support BigInt literal properties on objects/classes (without square brackets)

🔎 Search Terms

bigint literal object key class property

🕗 Version & Regression Information

  • This is a crash
  • This is the behavior in every version I tried (all the versions available in the TypeScript playground)

⏯ Playground Link

Playground link with relevant code

💻 Code

const obj = { 1n: 123 };

class A {
    1n = 123;
}

🙁 Actual behavior

Various parser errors:

  • The left-hand side of an assignment expression must be a variable or a property access.
  • Property assignment expected.
  • ';' expected.
  • Declaration or statement expected.
  • Unexpected token. A constructor, method, accessor, or property was expected.
  • Declaration or statement expected.

🙂 Expected behavior

Anything but a parser error

@MartinJohns
Copy link
Contributor

Is there any legit reason why you would write code like this?

@MartinJohns
Copy link
Contributor

Duplicate of #35982.

@almeidx almeidx closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2022
@fatcerberus
Copy link

It’s interesting that #35982 says this wasn’t implemented on purpose, since it’s legal JS syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants