Skip to content

Commit d6ea30e

Browse files
committed
[react] Remove Readonly<P> from class component constructor
This was added in 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.
1 parent 12df4a5 commit d6ea30e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

types/react/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ declare namespace React {
995995
*/
996996
context: unknown;
997997

998-
constructor(props: Readonly<P> | P);
998+
constructor(props: P);
999999
/**
10001000
* @deprecated
10011001
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}

types/react/ts5.0/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ declare namespace React {
996996
*/
997997
context: unknown;
998998

999-
constructor(props: Readonly<P> | P);
999+
constructor(props: P);
10001000
/**
10011001
* @deprecated
10021002
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}

0 commit comments

Comments
 (0)