Skip to content
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

Consider changing the next property type of the update object of the dispatchSetState function from any to null #30081

Closed
rbgksqkr opened this issue Jun 25, 2024 · 0 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@rbgksqkr
Copy link

rbgksqkr commented Jun 25, 2024

Hi!

It's not bug, but I think there is an unnecessary any type.
The type of the next property has changed since this commit.
I think the any type might be unstable. Considering future changes.

React version: 18.2.0

Steps To Reproduce

  1. Change the type of Update. (type Update<S, A> in ReactFiberHooks)
  2. Check for null in next where it is used.

Link to code example:

before

const update: Update<S, A> = {
  lane,
  revertLane: NoLane,
  action,
  hasEagerState: false,
  eagerState: null,
  next: (null: any),
};

after

export type Update<S, A> = {
  lane: Lane,
  revertLane: Lane,
  action: A,
  hasEagerState: boolean,
  eagerState: S | null,
  next: Update<S, A> | null,
};

const update: Update<S, A> = {
  lane,
  revertLane: NoLane,
  action,
  hasEagerState: false,
  eagerState: null,
  next: null,
};

The current behavior

When adding a function, the wrong type may be entered.

The expected behavior

Can improve type stability

@rbgksqkr rbgksqkr added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Jun 25, 2024
@rbgksqkr rbgksqkr changed the title onsider changing the next property type of the update object of the dispatchSetState function from any to null Consider changing the next property type of the update object of the dispatchSetState function from any to null Jun 25, 2024
@rbgksqkr rbgksqkr closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant