相关疑难解决方法(0)

Vue&TypeScript:在项目目录之外的TypeScript组件中实施导入时,如何避免错误TS2345?

尝试使用辅助组件(项目目录外部)时出现TypeScript错误:

TS2345: Argument of type '{ template: string; components: { SimpleCheckbox: typeof SimpleCheckbox; }; }' 
is not assignable to parameter of type 'VueClass<Vue>'.
Object literal may only specify known properties, and 'template' does not exist in type 
'VueClass<Vue>'.
Run Code Online (Sandbox Code Playgroud)

我的WebStorm IDE没有检测到此错误;当我使用TypeScript加载程序运行Webpack时,in在控制台中输出。

错误发生在:

import { Vue, Component, Prop } from 'vue-property-decorator';
import template from './SkipProjectInitializationStepPanel.pug';
import SimpleCheckbox from './../../../../ui-kit-libary-in-development/UiComponents/Checkboxes/MaterialDesign/SimpleCheckbox.vue';


@Component({ template, components: { SimpleCheckbox } }) // here !
export default class SkipProjectInitializationStepPanel extends Vue {
  @Prop({ type: String, required: true }) …
Run Code Online (Sandbox Code Playgroud)

typescript vue.js vue-component typescript-decorator typescript-definitions

5
推荐指数
1
解决办法
443
查看次数