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
[mjml-react] Add Explicit types for children #56254
[mjml-react] Add Explicit types for children #56254
Conversation
26b264f
to
846c753
Compare
@eps1lon Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PR
Code ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 56254,
"author": "eps1lon",
"headCommitOid": "a4ed8d569cd9c390609774f65e7a932ebbafb85e",
"lastPushDate": "2021-11-05T16:16:40.000Z",
"lastActivityDate": "2021-11-08T09:24:55.000Z",
"mergeOfferDate": "2021-11-08T02:39:07.000Z",
"mergeRequestDate": "2021-11-08T09:24:55.000Z",
"mergeRequestUser": "eps1lon",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"popularityLevel": "Well-liked by everyone",
"pkgInfo": [
{
"name": "mjml-react",
"kind": "edit",
"files": [
{
"path": "types/mjml-react/index.d.ts",
"kind": "definition"
},
{
"path": "types/mjml-react/mjml-react-tests.tsx",
"kind": "test"
}
],
"owners": [
"henrinormak",
"IanEdington"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "IanEdington",
"date": "2021-11-08T02:38:32.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 943377354,
"ciResult": "pass"
} |
🔔 @henrinormak @IanEdington — please review this PR in the next few days. Be sure to explicitly select |
IMO there's isn't enough detail about this change to evaluate what the goal is. This also changes tests in undesirable ways. Can you provide more info on this change? |
What details are you missing? I've provided a link to the overall goal and describe each individual component. I don't know what else I could provide.
Could you point to specifics? I'm not familiar with what you desire in your tests. |
const maxProps: React.ReactNode = <MjmlBreakpoint width="">child</MjmlBreakpoint>; | ||
const maxProps: React.ReactNode = <MjmlBreakpoint width="" />; | ||
} | ||
// TestMjmlBodyTag | ||
{ | ||
const minProps: React.ReactNode = <MjmlBody />; | ||
const minProps: React.ReactNode = <MjmlBody />; // $ExpectError |
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.
The tests shouldn't change should they?
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.
In general, they should. Specificaly, they change in any place where no children
where passed, even though that would throw at runtime,
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.
@IanEdington Please see https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-body.js#L8.
<MjmlBody />
would trigger prop-types warnings. Usually the TS types follow the prop-types. Is there any reason why we wouldn't do this here?
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 that's confusing. the mjml-react library isn't the most consistent unfortunately.
There is a case where the MjmlBody has to have no children:
export default function () {
return (
<Mjml>
<MjmlHead>
<MjmlAttributes>
<MjmlBody background-color="#FFFFFF" />
</MjmlAttributes>
<MjmlHead>
<Mjml>
);
}
I'll put in a PR on that repo.
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 we agree that the types match, can we merge this PR? If the maintainers decide to accept your PR we can always adjust the 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.
no because it will break existing valid typescript implementations. The prop-types are often not used since this is usually used as a server side react library to generate html. Emails that are written like this currently are valid in MJML which is the source of truth both mjml-react and the mjml-react 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.
no because it will break existing valid typescript implementations.
They're not valid though. DT types always follow the library types. We never intentionally deviate.
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. OK I'm not sure where to go from here.
The react binding types are out of sync with the component definition in mjml.
Merging this PR will result in a lot of errors for valid mjml.
I think we should fix this in the react bindings library.
I can open the PR to the mjml-react library tomorrow but it will probably take a few days to get it merged.
Can you wait for a couple more days to get this PR merged?
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.
@eps1lon the PR upstream has merged. Are you able to loosen the types in this PR?
My expectation is that you shouldn't need to change any tests from the base branch for this change. Does that make sense or is there something I'm still missing about the test changes?
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.
Updated types with wix-incubator/mjml-react#66
@eps1lon One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you! |
https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-wrapper.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-breakpoint.js#L10 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-font.js#L7 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-button.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-column.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-divider.js#L7 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-group.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-hero.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-image.js#L7 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-navbar.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-navbar-link.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-spacer.js#L7 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-table.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-wrapper.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-carousel.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-carousel-image.js#L10 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-social-element.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-social.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-section.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-column.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-button.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-text.js#L8 https://github.com/wix-incubator/mjml-react/blob/7894e20e52db6340e8bad2cbb731f6a3f2430db4/src/mjml-body.js#L8
cfc5234
to
a4ed8d5
Compare
@IanEdington Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
@eps1lon: Everything looks good here. I am ready to merge this PR (at a4ed8d5) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@henrinormak, @IanEdington: you can do this too.) |
Ready to merge |
We plan to remove implicit children from
@types/react
. The following changes are required to pass #56210.https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-wrapper.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-breakpoint.js#L10
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-font.js#L7
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-button.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-column.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-divider.js#L7
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-group.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-hero.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-image.js#L7
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-navbar.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-navbar-link.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-spacer.js#L7
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-table.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-wrapper.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-carousel.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-carousel-image.js#L10
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-social-element.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-social.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-section.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-column.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-button.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-text.js#L8
https://github.com/wix-incubator/mjml-react/blob/c1eb06ab366697a609dc6f552f86855b03ae4d80/src/mjml-body.js#L8