TSX Slot Type Missing / TSX 中使用插槽无类型推断 #10787
Unanswered
Kenhuey
asked this question in
Help/Questions
Replies: 2 comments
-
Found a weird way to have type Inference in Props define, works well, but I don't know if it will cause performance affecting / 发现一个可以用的邪道写法,写到 props 也有类型推断了,但是不知道会不会影响性能 import style from "./index.module.scss";
import { defineComponent, VNode } from "vue";
import { JSX } from "vue/jsx-runtime";
import { Render } from "@/application/core/render";
@Render.Component()
export class Popover extends Render.ComponentInstance {
public get() {
return defineComponent({
props: {
trigger: {
type: String as () => "hover" | "click",
required: true
},
slot: {
type: Object as () => {
triggerWrapper: () => VNode | JSX.Element;
default?: () => VNode | JSX.Element;
},
required: true
}
},
setup: (props) => {
return () => (
<div class={style["popover-container"]}>
{props.slot.triggerWrapper()}
<div></div>
</div>
);
}
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
And i tried / 然后我尝试了
Also Reference Type Missing / 引用组件的时候也没有类型提示
How do I fix it then type not missing? / 我应该怎么编写才能获得类型推断?
Beta Was this translation helpful? Give feedback.
All reactions