Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Cannot use class field #800

Closed
chungchi300 opened this issue May 6, 2019 · 4 comments
Closed

Cannot use class field #800

chungchi300 opened this issue May 6, 2019 · 4 comments
Labels

Comments

@chungchi300
Copy link

https://github.com/tc39/proposal-class-fields

@jdalton jdalton added the invalid label May 6, 2019
@jdalton
Copy link
Member

jdalton commented May 6, 2019

Hi @chungchi300!

We support parsing class fields. However, the Node version you use must support them.

@jdalton jdalton closed this as completed May 6, 2019
@chungchi300
Copy link
Author

I mean does it support ESnext Class Fields?
The class fields proposal allows properties to be initialized at the top of a class:

class MyClass {

  a = 1;
  b = 2;
  c = 3;

}

@jdalton
Copy link
Member

jdalton commented May 6, 2019

The esm loader supports whatever functionality native Node does. You can get class fields in Node 12 or --harmony I believe.

@dnalborczyk
Copy link
Contributor

@chungchi300 could you verify your node version?

either run node --version in the terminal, or check process.versions.node in your node app. if it's not at least v12.0, you have to either run node.js with the --harmony flag, as @jdalton suggested, or use a transpiler, like Babel.

if your node version is v12.x, and you are still running into this issue, could you provide some repro steps, or better, create a small repository?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants