`<Dynamic>` function prop args are `any`
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
11 Replies
Interesting :thinkies: Typescript just seems to give up
if you hover on the
onValueChange
prop it's typed correctly.
Maybe @jer3m01 or @Otonashi know why this is happeningafaict this is caused by https://github.com/solidjs/solid/pull/1248, which intentionally adds some magic to prevent the type of props from affecting the inferred type of
component
; not sure what to do about it
reverting the pr and applying
seems promising, but that breaks accessing props.component
so anyone relying on that will have to work around it
i'm not sure if there's a better supertype in this case, ideally it would be something like Component<{ [x: string]?: unknown }>
but that's invalid tsstrange thing is it seems to infer correctly when there's an error lol
tbh i don't know what i was doing playing around typescript with basic ts knowledge 😆
typescript often stops checking if there is an error at an other place. this is common
like multiple passes right? even then it would still check as much as possible. at least that's what it seems to me
not just any error that causes inference to change
my guess is if the shape of the props is invalid typescript recalculates them, otherwise it doesn't
jsx ignores properties with hyphens
not sure why the function call form works differently but changing the type of
value
gives a similar resultso initially it resolves
onValueChange
to any => any
, which will pass a check against the presumably later resolved generic constraint
however if the props fail overall then it'll rerun and narrow onValueChange
to string => void
(only to fail for the initial reason)
well everything is a guess without knowing ts internals