import Component1 from './Component1.svelte';
import Component2 from './Component2.svelte';
interface complexObject {
comp1 : Component1
comp2: Component2
}
let newComplexObj:complexObjects = {
comp1: Component1, <------ This is where error happens
comp2: Component2 <------- This is where error happens
}
类型'typeof Component1__SvelteComponent_'缺少以下属性类型'Component1__SvelteComponent_': $$prop_def, $$events_def, $$slot_def, $on和5 more.ts(2740)
这些是我的打字配置:
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictBindCallApply": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strict": true,
"importsNotUsedAsValues": "preserve"
}
它在浏览器中正确渲染,我在运行时没有错误,但在IDE中它显示了我的错误。
您不是在设置实例,而是在设置typeof
的构造函数。
interface complexObject {
comp1: typeof Component1,
comp2: typeof Component2,
}
(顺便说一下,这是错误消息的一部分,但在所有的噪音中很容易被忽略。)