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

Non-null assertion #64

Closed
filipigustavo opened this issue Sep 16, 2019 · 5 comments
Closed

Non-null assertion #64

filipigustavo opened this issue Sep 16, 2019 · 5 comments
Assignees

Comments

@filipigustavo
Copy link

Hi, I have a nuxt+typescript project and I'm getting this error:

error Parsing error: Unexpected token
4 | @component
5 | class ProductComponent extends Vue {
6 | @prop(Object) product!: Object
__ | ________________________^
7 | }
8 |
9 | export default ProductComponent


my tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/": [
"./
"
],
"@/": [
"./
"
]
},
"types": [
"@types/node",
"@nuxt/types"
],
"experimentalDecorators": true,
"resolveJsonModule": true
},
"exclude": [
"node_modules"
]
}


my .eslintrc.js:
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'@nuxtjs',
'plugin:nuxt/recommended',
'@nuxtjs/eslint-config-typescript'
],
// add your custom rules here
rules: {
"no-console": "off"
}
}


my package.json has these packages:
"dependencies": {
"@nuxtjs/axios": "^5.6.0",
"@nuxtjs/pwa": "^3.0.0-0",
"bootstrap": "^4.3.1",
"bootstrap-vue": "^2.0.1",
"nuxt": "^2.9.2",
"nuxt-property-decorator": "^2.4.0"
},
"devDependencies": {
"@nuxt/typescript-build": "^0.2.8",
"@nuxtjs/eslint-config": "^1.1.2",
"@nuxtjs/eslint-config-typescript": "^0.1.3",
"@nuxtjs/eslint-module": "^1.1.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.4.0",
"eslint-plugin-nuxt": ">=0.4.3",
"vuex-module-decorators": "^0.10.1"
}

I can't use the non-null assertion. How can I fix this problem?
This configuration was made following the instructions in https://typescript.nuxtjs.org

Thanks.

@b-barry
Copy link

b-barry commented Sep 18, 2019

Getting the same issue with a fresh nuxt + typescript setup

@axe-me
Copy link

axe-me commented Sep 19, 2019

save error, super annoying !

@axe-me
Copy link

axe-me commented Sep 19, 2019

finally found the reason, simply remove

parserOptions: {
  parser: 'babel-eslint'
}

in the .eslintrc.js
the reason is this parser is conflict with the parser used in this package.

@filipigustavo
Copy link
Author

finally found the reason, simply remove

parserOptions: {
  parser: 'babel-eslint'
}

in the .eslintrc.js
the reason is this parser is conflict with the parser used in this package.

Great, it's worked for me. Thanks.

@kevinmarrec
Copy link
Contributor

@nuxtjs/eslint-config-typescript set a TypeScript parser, so you need to not override it. (i.e. #64 (comment)). Thanks @axe-me

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