Closed as not planned
Closed as not planned
Description
For reasons [1] [2], I want to invoke Dynamic
as a function, not as JSX, like so:
const Child: VoidComponent = () => {
return <div>Child</div>;
};
const dynamic = Dynamic({
get component() {
return Child;
},
});
console.log(typeof dynamic) // function
console.log(dynamic()) // HTMLDivElement
Typescript says dynamic
is of type JSX.Element
, when really it is a function whose name is "bound readSignal"
.
More details that are probably not helpful but I spent too long writing to not include.
The same happens if I wrap `Dynamic` in a `createComponent`:const createDynamic = createComponent(Dynamic, {
get component() {
return Child;
},
});
console.log(typeof createDynamic) // function
console.log(createDynamic()) // HTMLDivElement
This does not occur for ordinary Components:
const ParentComp: VoidComponent<{
child: VoidComponent;
}> = () => {
return <div>ParentComp</div>;
};
const createParentComp = createComponent(ParentComp, {
get child() {
return Child;
},
});
const parentComp = ParentComp({
get child() {
return Child;
},
});
console.log(createParentComp) // HTMLDivElement
console.log(parentComp) // HTMLDivElement
Playground demoing Typescript errors: https://playground.solidjs.com/anonymous/1eaedcbb-4e59-445b-84cf-00b7792a983c
This change to Dynamic
was introduced in this v1.7 commit/PR, when Accessor<JSX.Element>
was removed from the return type and as unknown as JSX.Element
was added. The reasoning for this is unclear to me; the commit comment was "Remove FunctionElement from JSX.Element types". What work would need to be done to not lie to Typescript?
Metadata
Metadata
Assignees
Labels
No labels