-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Replace 2 occurrences of string in type ReactTestRendererJSON #8816
Replace 2 occurrences of string in type ReactTestRendererJSON #8816
Conversation
@iamdustan Can you please review this? |
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’m 90% certain this is okay, but want to confirm the possibly subtle differences between fiber and stack and the handling of numbers.
children : null | Array<ReactTestRendererNode>, | ||
$$typeof ?: Symbol, // Optional because we add it with defineProperty(). | ||
|}; | ||
type ReactTestRendererNode = ReactTestRendererJSON | string; | ||
type ReactTestRendererNode = ReactTestRendererJSON | ReactText; |
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 have to double-check, but I don’t think the fiber version would ever return a number since it’s always converted to strings inside fiber.
|
||
type ReactTestRendererJSON = {| | ||
type : string, | ||
props : {[propName: string] : string }, | ||
props : {[propName: string] : any }, |
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.
yeah, I think this is okay. I thought the same thing when grabbing this from the stack implementation. 👍
props: { [propName: string]: string }, | ||
children: null | Array<string | ReactTestRendererJSON>, | ||
props: { [propName: string]: any }, | ||
children: null | Array<ReactText | ReactTestRendererJSON>, |
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.
since stack and children behave in slightly different ways I do think that numbers are still numbers at this point, but once again I’ll need to confirm in a short while.
Thank you for reviewing. In case it helps you to understand what brought me here: test-rendering dom elements with only a relevant subset of props (given the purpose of that particular test) as the expected value for |
I reverted to |
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 this looks good @gaearon. Thanks @pedrottimark.
While studying implementation details of react-test-renderer, type
ReactTestRendererJSON
contradicted instead of confirmed what I had observed in Jest.To verify misleading Flow errors, I temporarily pasted an object as if from
renderer.create(<th colSpan={2}>{13}</th>).toJSON()
into ReactTestRendererFiber.js and ReactTestRendererStack.js:Currently the type is neither exported nor has an opportunity to report incorrect errors, but it could confuse people who read it as the specification of the object format from the test renderer.
any
too lax as the type for values ofprops
?ReactText
see https://github.com/facebook/react/blob/master/src/renderers/shared/fiber/isomorphic/ReactTypes.js#L24