-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix Wrong union description with TypeScript #1621 #1629
Conversation
I can't pass the CI steps of
@sapegin |
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.
Thanks for the pull request! This is a very useful feature. I've left a few general comments on the implementation but this is a very good start!
About the size checker: how much bigger it is now? It is here to avoid an accidental increase of the bundle size.
Actually the bundle size is increased |
That's the idea: the limit should be very close to the actual size so any increase is visible. Let's check again with custom styles, I believe they'll be much smaller. |
@sapegin Hi, I have updated my PR but I am still facing the CI step problem. |
Have you tried to update the limit? |
not yet. I can update it, but what do you think the next limit should be? |
Codecov Report
|
As I've already explained: as close as possible, so 1.15 should be fine. |
hmmm... I have no idea how to increase the coverage any further. |
I believe covering this line is the way: return <Type>unknown</Type>; |
Do you know what input to give to reach this case? |
function renderAdvancedType(type: TypeDescriptor): React.ReactNode { | ||
if (!type) { |
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.
@sapegin
I think the line above is usually unreachable code for now.
Because:
- The
type
passed to this function is based onprop.flowType
orprop.tsType
. - This function does not enter the branch unless
prop.flowType
orprop.tsType
is defined.
Therefore, what I can do is:
- Remove unreachable codes to increase coverage.
- Test only this function by itself to get the coverage
- Allow for this reduction in coverage.
what do you think?
I'd like to keep this line and test it on its own, as there may be some changes in the future that might unintentionally go into this branch. in my opinion tho.
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 think removing makes more sense — according to code and types it should be defined. And it would be great to fix type as any
on the call site.
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.
And it would be great to fix type as any on the call site.
good point. haha.
but It may be difficult in places where the type definitions are a bit mixed up.
I'll try it out for a bit, but if it's difficult, I think I'll ask for a review as it is.
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.
Thanks! Don't spend too much time on it though ;-)
@@ -58,7 +58,6 @@ declare module 'react-docgen' { | |||
| 'objectOf' | |||
| 'shape' | |||
| 'exact' | |||
| 'union' |
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.
duplicated definition for TypeUnionDescriptor
@sapegin please review me again when you have 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.
Very good, we're getting there! Just a few minor things left. 🦄
expect(container).toContainElement(getByTestId('child')); | ||
}); | ||
|
||
test('should the child component be wrapped by "role=button" element', () => { |
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.
Testing that this element is clickable and actually doing something (opening a tooltip) would be more useful, this test doesn't add value to other tests.
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.
it's fine to remove it as it's been tested in other cases.
await waitFor(() => | ||
expect(container.querySelector('[data-state="visible"]')).toBeInTheDocument() | ||
); | ||
expect(container.querySelector('[data-state]')).toHaveAttribute('data-state', 'visible'); |
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 line is the same assertion as the previous, so you can drop it.
export const styles = ({ space }: Rsg.Theme) => ({ | ||
complexType: { | ||
alignItems: 'center', | ||
cursor: 'pointer', |
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.
Shouldn't this be in the Tooltip component?
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 moved it to the tooltip, but the cursor didn't change as I expected, so I added a style here.
However, I think this cursor should change depending on the component it's wrapped around, so I would like to remove it for now.
alignItems: 'center', | ||
cursor: 'pointer', | ||
display: 'inline-flex', | ||
'& span': { |
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.
What's this span? Looks like this selector is very fragile and relies on the implementation of another component.
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.
Good point. this span is actually the icon. but I should have used a more safe way to avoid breaking.
@sapegin please review me again. |
@sapegin review me, please. |
Thanks, merging! Sorry for the delay ;-/ |
🎉 This PR is included in version 11.0.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolved:
Main changes:
ComplexType
andTooltip
to show the complex typeAdd styleMock in the test assets to mock CSS importHover Actions:
Keyboard Actions:
(use Tab key)