[英]vue-class-component mixins provoke an error in WebStorm?
I'm working on a project using vue-js and TypeScript. 我正在使用vue-js和TypeScript进行项目。 So I give vue-class-component
a try. 因此,我尝试了vue-class-component
。
I'm trying to code a mixin, it works well in VSC and VS but it seems that WebStorm is not really happy with my code. 我正在尝试编写一个混合代码,它在VSC和VS中都能很好地工作,但是WebStorm似乎对我的代码并不满意。
Here is the mixin : 这是mixin:
import Vue from 'vue'
import {StoreOptions} from 'vuex'
import Component from "vue-class-component";
@Component
export default class Container extends Vue {
registerStoreModule(key: string, module: StoreOptions<any>): void {
if (!this.$store.state[key]) {
this.$store.registerModule(key, module);
}
}
}
And here is the component using this mixin : 这是使用此mixin的组件:
@Component({
components: { UserCard },
computed: mapGetters({ user: `${STORE_KEY}/user` })
})
export default class UserContainer extends mixins(Container) {
user: UserState;
created() {
this.registerStoreModule(STORE_KEY, store)
}
mounted() {
this.$store.dispatch(`${STORE_KEY}/getUser`);
}
}
According to vue-class-component , this should work. 根据vue-class-component ,这应该工作。 The thing is that WebStorm is failing at checking TypeScript types. 事实是,WebStorm无法检查TypeScript类型。
There are 2 errors : 有2个错误:
The code compiles well and other IDEs don't catch those errors. 代码可以很好地编译,而其他IDE不会捕获这些错误。 I've tried with different versions of TS, currently I'm using 2.8.3. 我尝试使用不同版本的TS,目前使用的是2.8.3。 Visual Studio Code uses the same version as WebStorm. Visual Studio Code使用与WebStorm相同的版本。
EDIT: Here is my tsconfig.json, it can be useful :) 编辑:这是我的tsconfig.json,它可能有用:)
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"node",
"mocha",
"chai"
],
"paths": {
"@/*": [
"src/*"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.vue",
"tests/**/*.ts"
],
"exclude": [
"node_modules"
]
}
已知问题,请按照WEB-31543进行更新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.