這里的回傳型別是什么?
路徑值是一個回傳元素的函式。
export type iconName = "logo";
type icon = {
viewBox: string;
paths: () => ??;
};
const IconSet: Record<iconName, icon> = {
logo: {
viewBox: "0 0 20 20",
paths: () => (<div>...</div>),
},
};
export { IconSet };
我只想在js中這樣使用
export const test = {
a : () => {return (
<div>...</div>
)}
}
我的 package.json 檔案

和 tsconfig 檔案在這里

uj5u.com熱心網友回復:
您可以JSX.Element從回傳 JSX 元素的 e 函式回傳:
type icon = {
viewBox: string;
paths: () => JSX.Element;
};
const IconSet: Record<iconName, icon> = {
logo: {
viewBox: "0 0 20 20",
paths: () => (<div>...</div>),
},
};
游樂場鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/414471.html
標籤:
