-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(router): Better autocomplete for <Set>
s
#11769
Conversation
I'm trying this in VSCode … still does not solve 3. and 9. in our text case matrix for me :( But i see that 9. is actually working for the very first element in the array (in current |
Thanks for testing this @Philzen. Now, can you please try three more things for me? Try these one at a time
Did any of the above changes fix the types for you? |
Oh boy, i just found a really important detail. It does matter whether the props are typed with That is something to keep in mind while debugging … interfaces can be extended in-place, while types need to extend via intersection: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces Note that the generated
On it. |
Interesting 🤔 … i have However in both cases it stops complaining as soon as i have filled in one components' required props, if won't care which.
Cannot see any difference.
No help.
|
After a restart i cannot reproduce what went wrong there on my side. I can confirm what you are seeing now. Looks good. |
@Tobbe did you test that this doesn't introduce a regression for #11739? If i try out this PR, i get TS errors and no autocompletion for any props on https://raw.githubusercontent.com/redwoodjs/redwood/6cfc992c35a06307bc703c402296b86ae58873f4/packages/router/src/Set.tsx currently is still the version that works best for me, but maybe you can fix |
I just made a totally separate type for private sets (for now). We can come back and iterate later.
Does this still hold true now when |
No, this version works for me now 😺 Check out my review comment – extracting that complex type may save some duplication and makes the TS evaluation faster. Otherwise i'm completely OK with this PR, cheers. |
Did you forget to publish it? I don't see any review comments |
? React.ComponentProps<P> | ||
: P extends React.FC<any>[] | ||
? React.ComponentProps<P[0]> & | ||
React.ComponentProps<P[1]> & | ||
React.ComponentProps<P[2]> & | ||
React.ComponentProps<P[3]> & | ||
React.ComponentProps<P[4]> & | ||
React.ComponentProps<P[5]> & | ||
React.ComponentProps<P[6]> & | ||
React.ComponentProps<P[7]> & | ||
React.ComponentProps<P[8]> & | ||
React.ComponentProps<P[9]> | ||
: unknown) & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side-note: it is recommended to extract this into a separate type as per https://github.com/microsoft/TypeScript/wiki/Performance#naming-complex-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried extracting this. But when I do TS just always seems to resolve it to unknown
.
But I did some other changes, so now at least all of the Set type isn't duplicated.
Apparently 🤦 😆 |
@Philzen Feel free to have a swing at extracting that big complicated type if you want |
…)" This reverts commit 9e6b769.
This is a continuation of #11756 to provide autocomplete for the wrapper props
There's a limit to 10 wrapper components. After that additional props will not be included. To work around this you can either make sure to put wrapper components that doesn't require any props last, or just split your wrappers between multiple
<Set>
s