-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type checking does not carry across spreading ...$$restProps
#1363
Comments
The component could be used in many different circumstances, so it's not clear statically what |
Hmm not sure I understand. What's an example of this? I don't see any reason in principle why the example repo I linked could not be typed better. The props: {
name?: string;
}; The props: {
[x: string]: any;
}; It doesn't matter what circumstances either of these two components are used in, you only have to analyze the components themselves to type them properly. |
After poking around the svelte2tsx code a little bit, maybe I understand better. You're worried about dynamic access, like However going back to:
I'm still not sure that's true. On the balance that's probably true for However I would also believe you if you said that this was far too complicated to add (I don't really know) and that I need to just convert all my components over to |
You want the type of |
You're right, that makes sense. Thanks for the explanation. |
Describe the bug
If a component
A
spreads its$$restProps
to some child componentB
, andB
has some typed propfoo
, then anyfoo
which is passed toA
should be checked against the type specified inB
. For example, ifB
specifies thatfoo
is a string, then<A foo={console.log}>
should give a type error. Right now it does not.For that matter, you can also just pass invalid props to
A
which don't actually exist onA
orB
, and no error will be thrown.I can imagine why this could get complicated, but it'd still be really nice if it worked. I ran into this trying to make some TypeScript improvements in
svelte-headlessui
To Reproduce
I created a repo for ease of illustration: https://github.com/rgossiaux/svelte-prop-spread-ts
Expected behavior
See repo
Screenshots
N/A
System (please complete the following information):
svelte-check
v2.4.1The text was updated successfully, but these errors were encountered: