Greetings,
I've encountered a strange issue. I'm working on a Nuxt app with Typescript. In the created
hook, I am using console.log
to log this.$route
. The log is functioning correctly and I am able to read the params from the route.
However, during the app build process, I am receiving an error in the console:
Property
$route
does not exist on typeSomeClass
.
Below is my class structure:
import Vue from'vue'
import Component from 'vue-class-component'
@Component
export default class SomeClass extends Vue {
public id!: string
created() {
console.log('this:', this)
this.id = this.$route.params.id
}
}
The console.log
displays the correct route and its parameters without any issues.
How can I resolve this error?
Here is a snippet of my tsconfig.json file:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app",
"element-ui/types"
]
}
}