vue-cliのプロジェクトにおいて、
class AuthService extends EventEmitter {
idToken = null // ←これがエラーになる
profile = null
tokenExpiry = null
// Starts the user login flow
login (customState) {
webAuth.authorize({
appState: customState
})
}
...
}
こういう書き方をすると、
Syntax Error: Unexpected token (9:10)
7 |
8 | class AuthService extends EventEmitter {
> 9 | idToken = null;
| ^
10 | profile = null;
11 | tokenExpiry = null;
12 |
こんな文法エラーぽいのがでた。
package.json
に
...
"devDependencies": {
"@babel/polyfill": "^7.4.4",
"@vue/test-utils": "^1.0.0-beta.29",
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^24.8.0",
"babel-loader": "^7.1.1",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
+ "babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
.babelrc
+ "plugins": ["transform-runtime", "transform-class-properties"],
でエラーが解消された。