io.js, ES6: TypeError: Class constructors cannot be invoked without 'new'
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 312
- PR merge metrics
- No merged PRs in 30d
Description
When trying to run server-side using io.js (2.3.3) using es6 classes i get the following error:
```
/Users/josef/Develop/some/some-app/src/js/shared/stores/some-store.js:43
constructor() {
^
TypeError: Class constructors cannot be invoked without 'new'
at Store.SomeStore (/Users/josef/Develop/some/some-app/src/js/shared/stores/some-store.js:43:14)
at new Store (/Users/josef/Develop/some/some-app/node_modules/alt/lib/store/index.js:139:73)
at Object.createStoreFromClass (/Users/josef/Develop/some/some-app/node_modules/alt/lib/store/index.js:160:15)
at Alt.createStore (/Users/josef/Develop/some/some-app/node_modules/alt/lib/index.js:116:109)
...
```
From a store in this format:
```
'use strict';
var alt = require('../alt'),
someActions = require('../actions/some-actions'):
class SomeStore {
constructor() {
this.state = {};
this.bindListeners({
onSomeCreated: someActions.someCreated
});
}
onSomeCreated(some) {
}
}
module.exports = alt.createStore(SomeStore, 'SomeStore');
```
Is there some configuration that should be set for alt to know how initialisation should happen? Or could I be missing some other obvious thing?
Contributor guide
Research direction
Start with the reproduced stack trace in src/js/shared/stores/some-store.js and trace the createStore and createStoreFromClass calls shown in alt/lib/store/index.js. Determine whether io.js 2.3.3 requires configuration or a supported store-class initialization path, then verify the result against the reported ES6 class example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100