diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 49224d93cf..2ed2fb497c 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -404,7 +404,7 @@ declare namespace React { * * Note: its presence prevents any of the deprecated lifecycle methods from being invoked */ - (nextProps: Readonly

, prevState: Readonly) => Partial | null; + (nextProps: Readonly

, prevState: S) => Partial | null; // This should be "infer SS" but can't use it yet interface NewLifecycle { diff --git a/types/react/test/tsx.tsx b/types/react/test/tsx.tsx index b086e35f9f..760a625cfd 100644 --- a/types/react/test/tsx.tsx +++ b/types/react/test/tsx.tsx @@ -156,6 +156,7 @@ class ComponentWithLargeState extends React.Component<{}, Record<'a'|'b'|'c', st return { a: 'a' }; } } +const AssignedComponentWithLargeState: React.ComponentClass = ComponentWithLargeState; const componentWithBadLifecycle = new (class extends React.Component<{}, {}, number> {})({}); componentWithBadLifecycle.getSnapshotBeforeUpdate = () => { // $ExpectError