Skip to content

[react] Remove Readonly<P> from class component constructor#69140

Merged
typescript-bot merged 2 commits intoDefinitelyTyped:masterfrom
eps1lon:react/test-readonly-props-in-constructor
Mar 25, 2024
Merged

[react] Remove Readonly<P> from class component constructor#69140
typescript-bot merged 2 commits intoDefinitelyTyped:masterfrom
eps1lon:react/test-readonly-props-in-constructor

Conversation

@eps1lon
Copy link
Copy Markdown
Collaborator

@eps1lon eps1lon commented Mar 23, 2024

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.

eps1lon added 2 commits March 23, 2024 18:13
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 eps1lon marked this pull request as ready for review March 23, 2024 17:37
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Mar 23, 2024

@eps1lon Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because 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

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by a DT maintainer

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"
}

@typescript-bot typescript-bot added Critical package Author is Owner The author of this PR is a listed owner of the package. labels Mar 23, 2024
@typescript-bot
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@peterblazejewicz peterblazejewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eps1lon at your discretion, thx!

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Mar 24, 2024
@typescript-bot
Copy link
Copy Markdown
Contributor

@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:

Ready to merge

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.)

@eps1lon
Copy link
Copy Markdown
Collaborator Author

eps1lon commented Mar 25, 2024

Ready to merge

@typescript-bot typescript-bot merged commit 83ced69 into DefinitelyTyped:master Mar 25, 2024
@eps1lon eps1lon deleted the react/test-readonly-props-in-constructor branch March 25, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author is Owner The author of this PR is a listed owner of the package. Critical package Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants