Interface 'NuxtApp' incorrectly extends interface 'Vue'.
Types of property '$loading' are incompatible.
Type 'NuxtLoading' is not assignable to type '(options: LoadingServiceOptions) => ElLoadingComponent'.
Type 'NuxtLoading' provides no match for the signature '(options: LoadingServiceOptions): ElLoadingComponent'.
88 | }
89 |
> 90 | export interface NuxtApp extends Vue {
| ^
91 | $options: NuxtAppOptions
92 | $loading: NuxtLoading
93 | context: Context
ℹ Version: typescript 3.6.4
如上所示,nuxt社区本来就少,nuxt + ts社区更是少之又少,这个问题很少会有人碰到,但还是记录下来。万一呢。
原因是
所以在.tsconfig.json中加入
"skipLibCheck": true,
变成
{
"compilerOptions": {
"skipLibCheck": true, // 新增到这里
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/types"
]
},
"exclude": [
"node_modules",
"**/__tests__/",
"**/tmp"
]
}
跳过检查就好了。