[react] Remove Readonly<P> from class component constructor#69140
Conversation
…ture does not do anything
This was added in DefinitelyTyped@542f3c0 without adding tests validating the behavior. It certainly doesn't work anymore since the added tests also passed with `Readonly<P>`. Maybe it did work but then the change will almost certainly be marked as working as intended. So I just remove it now since a lot of the ecosystem have inlined their own class component constructor without Readonly<P> that matches the legacy context constructur signature. Legacy context will be removed in React 19 so we would break a lot of existing code for a feature that doesn't even work.
|
@eps1lon Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PRCode ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. 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": 69140,
"author": "eps1lon",
"headCommitOid": "d6ea30e3cdf3c26f9cd15c702d225e1a34169e41",
"mergeBaseOid": "e1386bb7838c35504edfdb12876bf0d156d84a2a",
"lastPushDate": "2024-03-23T17:21:30.000Z",
"lastActivityDate": "2024-03-25T09:17:42.000Z",
"mergeOfferDate": "2024-03-24T20:18:56.000Z",
"mergeRequestDate": "2024-03-25T09:17:42.000Z",
"mergeRequestUser": "eps1lon",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "react",
"kind": "edit",
"files": [
{
"path": "types/react/index.d.ts",
"kind": "definition"
},
{
"path": "types/react/test/index.ts",
"kind": "test"
},
{
"path": "types/react/ts5.0/index.d.ts",
"kind": "definition"
},
{
"path": "types/react/ts5.0/test/index.ts",
"kind": "test"
}
],
"owners": [
"johnnyreilly",
"bbenezech",
"pzavolinsky",
"ericanderson",
"DovydasNavickas",
"theruther4d",
"guilhermehubner",
"ferdaber",
"jrakotoharisoa",
"pascaloliv",
"hotell",
"franklixuefei",
"Jessidhia",
"saranshkataria",
"lukyth",
"eps1lon",
"zieka",
"dancerphil",
"dimitropoulos",
"disjukr",
"vhfmag",
"hellatan",
"priyanshurav",
"Semigradsky",
"mattpocock"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "peterblazejewicz",
"date": "2024-03-24T20:18:12.000Z",
"isMaintainer": true
}
],
"mainBotCommentID": 2016557057,
"ciResult": "pass"
} |
|
🔔 @johnnyreilly @bbenezech @pzavolinsky @ericanderson @DovydasNavickas @theruther4d @guilhermehubner @ferdaber @jrakotoharisoa @pascaloliv @Hotell @franklixuefei @Jessidhia @saranshkataria @lukyth @zieka @dancerphil @dimitropoulos @disjukr @vhfmag @hellatan @priyanshurav @Semigradsky @mattpocock — please review this PR in the next few days. Be sure to explicitly select |
peterblazejewicz
left a comment
There was a problem hiding this comment.
@eps1lon at your discretion, thx!
|
@eps1lon: Everything looks good here. I am ready to merge this PR (at d6ea30e) 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! ❤️ (@johnnyreilly, @bbenezech, @pzavolinsky, @ericanderson, @DovydasNavickas, @theruther4d, @guilhermehubner, @ferdaber, @jrakotoharisoa, @pascaloliv, @Hotell, @franklixuefei, @Jessidhia, @saranshkataria, @lukyth, @zieka, @dancerphil, @dimitropoulos, @disjukr, @vhfmag, @hellatan, @priyanshurav, @Semigradsky, @mattpocock: you can do this too.) |
|
Ready to merge |
constructor(props: Readonly<Props>)was added in #26813 without adding tests validating the behavior.It certainly doesn't work anymore since the added tests also passed with
Readonly<P>.Maybe it did work but then the change will almost certainly be marked as working as intended.
So I just remove it now since a lot of the ecosystem have inlined their own class component constructor without
Readonly<P>that matches the legacy context constructur signature.Legacy context will be removed in React 19 so we would break a lot of existing code for a feature that doesn't even work.
We still guard against mutating props when updating
this.props. Just not the props that were passed to the constructor.