Keysinnovation Keysinnovation - 1 year ago 126
Javascript Question

static class property not working with Babel

I am using JSDOC and all it supported npm plugins to create nice documentation. Getting hard time when jsdoc is running and parsing JSX file it always throws error as below near


SyntaxError: unknown: Unexpected token
export default class SaveDesign extends Component {
static displayName = 'SaveDesign';

conf.json file

"source": {
"include": [ "src/app/test.js", "src/app/components/Modals/Template/SaveDesign.jsx"],
"exclude": [ "src/fonts", "src/icons", "src/less", "src/vector-icon" ],
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
"plugins": ["node_modules/jsdoc-babel"],
"babel": {
"extensions": ["js", "es6", "jsx"],
"presets": ["es2015"]
"jsx": {
"extensions": ["js", "jsx"]

Answer Source

Class properties aren't part of the ES2015 spec, so they're not part of the ES2015 Babel preset either. The proposal to add class properties to the language is currently at Stage 2 of the standardization process, so you need the Stage 2 preset.

Alternatively, you could just install the class properties plugin on its own:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download