Skip to content
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

JS_SYNTAX_ERROR from seemingly valid code #3673

Closed
dr-off opened this issue Apr 13, 2021 · 7 comments
Closed

JS_SYNTAX_ERROR from seemingly valid code #3673

dr-off opened this issue Apr 13, 2021 · 7 comments

Comments

@dr-off
Copy link

dr-off commented Apr 13, 2021

Describe the problem and steps to reproduce it:

I am trying to submit an update for my web extension but the validation fails due to this code:

class Setting
{
	static instances = [];
	static instancesById = {};

	static categories = new Map();

       // Irrelevant code truncated, the full file is linked at the end of this issue.
}

You can reproduce it by including this code in a web extension.

What happened?

A JS_SYNTAX_ERROR is shown:

JavaScript syntax error (Parsing as module error:
Unexpected token = at line: 3 and column: 19)
(Parsing as script error: Unexpected token = at
line: 3 and column: 19)

This code works fine in Firefox and Chrome and seems valid by all accounts I can find but for some reason, the linter considers it invalid.

What did you expect to happen?

I would expect it to consider this valid.

Anything else we should know?

The full code of the class can be found in my repo here.

@dr-off dr-off changed the title Unexpected token error in perfectly valid code Unexpected token error in seemingly valid code Apr 13, 2021
@dr-off dr-off changed the title Unexpected token error in seemingly valid code JS_SYNTAX_ERROR from seemingly valid code Apr 13, 2021
@willdurand
Copy link
Member

This code works fine in Firefox and Chrome and seems valid by all accounts I can find but for some reason, the linter considers it invalid.

Hi, is this the entire message? You should have a message about unsupported syntax, which is valid but not supported yet because not "fully standardized".

@dr-off
Copy link
Author

dr-off commented Apr 13, 2021

My apologies, I should've included the description as well.

There is a JavaScript syntax error in your code, which might be related to some experimental
JavaScript features that aren't an official part of the language specification and therefore not
supported yet. The validation cannot continue on this file.

Is assigning static variables in this way not a standardized feature?

@willdurand
Copy link
Member

Please see: #3062

@dr-off
Copy link
Author

dr-off commented Apr 13, 2021

Hmm, I see. So I basically just have to work around this for now then?

@willdurand
Copy link
Member

Hmm, I see. So I basically just have to work around this for now then?

Yes, unfortunately we don't have a good workaround for that.

@erosman
Copy link
Contributor

erosman commented Apr 14, 2021

So I basically just have to work around this for now then?

ATM, you have to define them outside the class body.

Instance properties

Static (class-side) data properties and prototype data properties must be defined outside of the ClassBody declaration:

@wagnerand
Copy link
Member

Closing as duplicate of #3062.

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

4 participants