You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following class, I have a simple static initialization block that sets a static property. When I run parcel build, it throws compilation error, coming out of parcel transformer.
exportdefaultclassMyClass{staticprop="somevalue";static{console.log("I am in static block");MyClass.prop="changing the val";}staticprintVal=()=>{console.log(`Value is : ${MyClass.prop}`);};}
The error being thrown is -
× Build failed.
@parcel/transformer-js: Unexpected token {. Expected identifier, string literal, numeric literal or [ for the computed key
C:\dev\parcelstatic\staticClass.js:4:10
3 |
4 | static {
| ^
5 | console.log("I am in static block");
6 | MyClass.prop = "changing the val";
🐛 bug report
In the following class, I have a simple static initialization block that sets a static property. When I run parcel build, it throws compilation error, coming out of parcel transformer.
The error being thrown is -
× Build failed.
@parcel/transformer-js: Unexpected token
{
. Expected identifier, string literal, numeric literal or [ for the computed keyC:\dev\parcelstatic\staticClass.js:4:10
3 |
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
I should be able to use static initialization blocks.
😯 Current Behavior
Using static initialization blocks in your class breaks the build.
💁 Possible Solution
🔦 Context
💻 Code Sample
🌍 Your Environment
The text was updated successfully, but these errors were encountered: