Я работаю над проектом, используя Vue 2 и TS. При компиляции кода вылетают следующие ошибки:
Property '$route' does not exist on type 'Имя компонента'.
Property "$router" does not exist on type 'Имя компонента'.
Мой tsconfig
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitThis": false,
"downlevelIteration": true,
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types",
"./src/@types/",
],
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
Мой shims файл для роутера
import { VueRouter } from "vue-router/types/router";
import { Route } from "vue-router";
declare module "vue/types/vue" {
interface VueConstructor {
$router: VueRouter;
$route: Route;
}
}
файлы находятся в project_name/src/@types/