Reputation: 237
What would the return type be here?
the paths value is a function that returns an element.
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 };
I just want to use it like this in js
export const test = {
a : () => {return (
<div>...</div>
)}
}
my package.json file
and tsconfig file here
Upvotes: 0
Views: 52
Reputation: 249746
You can return JSX.Element
from e function that return a JSX element:
type icon = {
viewBox: string;
paths: () => JSX.Element;
};
const IconSet: Record<iconName, icon> = {
logo: {
viewBox: "0 0 20 20",
paths: () => (<div>...</div>),
},
};
Upvotes: 1