S
SolidJS2mo ago
Jakob

`<Dynamic>` function prop args are `any`

Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
No description
11 Replies
Jasmin
Jasmin2mo ago
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 happening
Otonashi
Otonashi2mo ago
afaict 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
- export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
+ export type ValidComponent = keyof JSX.IntrinsicElements | Component<never> | (string & {});
- export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
+ export type ValidComponent = keyof JSX.IntrinsicElements | Component<never> | (string & {});
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 ts
mdynnl
mdynnl5w ago
strange thing is it seems to infer correctly when there's an error lol
No description
mdynnl
mdynnl5w ago
tbh i don't know what i was doing playing around typescript with basic ts knowledge 😆
Jasmin
Jasmin5w ago
typescript often stops checking if there is an error at an other place. this is common
mdynnl
mdynnl5w ago
like multiple passes right? even then it would still check as much as possible. at least that's what it seems to me
No description
Otonashi
Otonashi5w ago
No description
Otonashi
Otonashi5w ago
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
Otonashi
Otonashi5w ago
not sure why the function call form works differently but changing the type of value gives a similar result
No description
Otonashi
Otonashi5w ago
so 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
Want results from more Discord servers?
Add your server
More Posts
how to deploy a website built with the solid.js framework on vercel?; troubleshootingI deployed my Solid.js project on Vercel using GitHub, initially selecting Vite as the framework. HoWrapping `<FileRoutes />` in `ErrorBoundry`Im trying to migrate from the pre 1.0 day, when `solid-start` cli was still a thing. Back then I wasHow do I build my component?Hi guys 👋 I'm a bit confused about how I could build a SolidJS component into JS that I could publPractice of handling application globals in Solid(Start) symmetrically across client and server?Example: In the CSR-only days it was idiomatic to store context value as a module-global value: `Ideal way to load settings/configsSuppose I have a bunch of settings like user preferences (dark mode), or configs which I load using How to call `useNavigate` outside of routerI am trying to create my own "page viewer" where I will be able to navigate between pages within theHydration Mismatch Error Every Time I Update a ComponentI am rewriting an OAuth2 service for one of my apps in SolidStart. I keep getting this error every tHow can I synchronize two stores without running into an infinite loop?The following code triggers an infinite loop: ```ts const [store1, setStore1] = createStore({a: 1, What is the most idiomatic way of disabling an effect after a condition is met?Is it possible to disable an effect after some condition is met or should I just use an early returnpage refresh taking alot of time or may be not loadingI'm new to Solid.js, and I'm facing a problem with browser refreshing. When I make changes to my pro