-
Notifications
You must be signed in to change notification settings - Fork 208
fix(css-properties): remove incorrect React.ReactChild from Lossy Union #372
fix(css-properties): remove incorrect React.ReactChild from Lossy Union #372
Conversation
Codecov Report
@@ Coverage Diff @@
## master #372 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 10 10
Lines 182 182
Branches 52 52
=====================================
Hits 182 182 Continue to review full report at Codecov.
|
7b5ad84
to
7912617
Compare
This clearly looks like a better solution. However, with TypeScript 2.6.1 your PR fails to typecheck my codebase. <Div height={18}>
<MyComponent />
</Div>
I don’t understand why, since the test cases clearly include this. :-( |
a10f44d
to
4a1598c
Compare
🤔 Are you able to share a version of I've added additional cases to test component signatures being accepted as children to this pr. https://github.com/luke-john/glamorous/blob/4a1598ca1a97d72c02ab54ecaccea3a1b9d8133c/test/glamorous.test.tsx#L568-L585 |
actually are you sure you're using this version? I'm a little bit suspicious of that error containing
|
Hm, strange. I will test more thoroughly in the next day or two. |
@luke-john, @denis-sokolov is right. {
[propertyName: string]: T
}
|
@@ -1926,7 +1926,6 @@ export interface CSSPropertiesLossy { | |||
| undefined | |||
| Array<CSSPropertiesComplete[keyof CSSPropertiesComplete]> | |||
| CSSPropertiesLossy | |||
| React.ReactChild |
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.
This will cause the same problem of #353
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.
This is the minimal PoC for common problem.
https://goo.gl/kjc8XD
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.
IMO, to remove this extra union (as we want), we need to solve #353 first.
Ahh right, cheers for that @Ailrun, I've recently left my last workplace so don't have any large codebases to test prs on at the moment. Something is clearly going wrong here as the type for glamorous.Div is not matching the type for the named export Div. |
🤦♂️ Ahh I forgot to read the important comment at the top of that file
will update shortly. thanks |
4a1598c
to
5716958
Compare
> | ||
Wbr: React.StatelessComponent< | ||
CSSProperties & ExtraGlamorousProps & React.HTMLProps<HTMLElement> | ||
CSSPropertiesCompleteSingle & |
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.
So being unable to use ':active'
or other pseudo properties works as intended?
I mean,
const props = {
':active': {
color: 'purple'
}
};
<glamorous.A {...props} />
Is invalid?
I beg your understanding for my ignorance of whole project structure itself. (I just skim whole codes after I became a collaborator, because of lack of time...)
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.
hmm, I hadn't really thought about spreading the css props on.
🤔 That is valid, but as I understood it the purpose of that api was to make it possible to simple add css properties like follows;
<glamorous.A color="purple" />
And for the pattern you're describing do something like follows
const cssProps = {
':active': {
color: 'purple'
}
};
<glamorous.A css={props} />
I'm leaning towards making the types simpler here to reflect the intended use. As otherwise it makes the types less useful elsewhere.
Really appreciate your feedback and taking the time to go over these prs and even skimming the code 💖.
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.
We could add CSSPropertiesPseudo
to the Intersection which would allow the case you've raised to work. But it would still fall down on things like
const props = {
'> span': {
color: 'purple'
}
};
<glamorous.A {...props}>hello <span>world</span></glamorous.A>
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.
Thank you for your kind answer!
I think I fully get the point what you want to say, and I agree with it to some distance. I will approve this PR.
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've added test cases for the pseudo props as part of this pr as well, cheers.
This was originally added to fix a problem where built in glamorous components had been typed to accept the css properties union which included the lossy version. By updating that component to instead use the css CompleteSingle interface the React.ReactChild is able to be removed.
5716958
to
a821469
Compare
@luke-john Following is just a question. If you give me an answer, I would greatly appreciate it. Is there any reason for dismissing the review? |
My speculation would be Luke wanted to express a need for you to review it afresh after the latest changes, @Ailrun. I promised to test this again until today, @luke-john, but my schedule can’t allow it, apologies. I won’t be able to reproduce it until the weekend. |
@Ailrun I pushed the And GitHub automatically dismisses reviews when changes are made to a pull request. |
@luke-john Thank you for explanation! I didn't know there's a case that github automatically dismisses a review. |
And also thank you for @denis-sokolov to try to explain what I ask! I really appreciate you all! |
GitHub does not always automatically dismiss a review, it’s a per-repository setting. Some people want to make sure that the reviewers have seen the absolutely latest version of the PR, and some are okay with relying on a more lax rule of common sense. |
I’m confused by my tests. Minimal case that triggers the error with this branch as the dependency is this: <Div>
<Div />
</Div> Obviously it is supposed to be covered in tests, but I was pretty thorough with the tests. Building This happens with tsc 2.6.1 and 2.6.2, confirmed the flow with both. Here is the error:
|
This looks awesome! Is there an ETA to release? |
@TeffenEllis Sorry for late response. @kentcdodds could you answer to @TeffenEllis ? |
The releases for this project are automatic. So it should be released as soon as this is merged. |
@kentcdodds Oh, I mean... when will this merged? |
I keep out of typescript related stuff unless specifically asked. Do you all my help here? Feel free to merge typescript pull requests yourself. Just make sure to follow the commit message convention when doing squash and merge so the right version is released. |
@kentcdodds I got |
cdc9dbc
to
a821469
Compare
It's because the PR was not updated with Just make sure to follow the commit message conventions when you squash and merge, otherwise a new version will not be released. Cheers! And thanks! |
@luke-john Please update your snapshots. |
Have just updated the tests, I'm unsure about merging this though as we never worked out why this was causing additional failures #372 (comment). I've tried to reproduce without luck, however have added a test case for this which does not appear to fail. Also sorry for the huge delay here, I've just relocated to London from Australia and my life has been a bit hectic lately. |
thanks for following this up @Ailrun |
@luke-john it looks like @denis-sokolov miss something (or we miss some updates) since error message includes P.S. I cannot reproduce it. |
@kentcdodds I still cannot merge this. |
Oh, that's because you're the one who approved it. Need to have someone else merge it. I guess that can be me! :) |
What:
Remove React.ReactChild from css properties Lossy Unions
This was originally added to fix a problem where built in glamorous components had been typed to accept the css properties union which included the lossy version.
By updating that component to instead use the css CompleteSingle interface the React.ReactChild is able to be removed.
Checklist: