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

Adds missing Context and Dispatch types to compat #4028

Merged
merged 4 commits into from
May 26, 2023

Conversation

Scott-Fischer
Copy link
Contributor

@Scott-Fischer Scott-Fischer commented May 24, 2023

Adds two missing types to the exported React namespace in compat.
Closes #4027

  • React.Dispatch (sourced from here)
  • React.Context (this one already existed under preact.Context, it just is not being re-exported under the React namespace)

@Scott-Fischer Scott-Fischer changed the title adds missing react types to compat Adds missing react types to compat May 24, 2023
@@ -30,6 +30,7 @@ declare namespace React {
export import useReducer = _hooks.useReducer;
export import useRef = _hooks.useRef;
export import useState = _hooks.useState;
export type Dispatch<A> = (value: A) => void;
Copy link
Member

@rschristian rschristian May 24, 2023

Choose a reason for hiding this comment

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

Suggested change
export type Dispatch<A> = (value: A) => void;
export type Dispatch<A> = (action: A) => void;

Might be worth extracting to core hook's types for reuse in submodules, not sure. We do use it in a few different places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rschristian Do you mean define the type in ./src/index.d.ts as part of preact's namespace and re-export in the compat types via ./compat/src/index.d.ts?

Copy link
Member

@rschristian rschristian May 24, 2023

Choose a reason for hiding this comment

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

Whoops, sorry. Not to core, but to /hooks/src/index.d.ts, as it can be used in useReducer's types quite nicely and re-exported through compat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay sounds good. I'm making this change now then will mark this as ready for review.

Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
@coveralls
Copy link

coveralls commented May 26, 2023

Coverage Status

Coverage: 99.705%. Remained the same when pulling dbb6b97 on Scott-Fischer:master into fb8cfa9 on preactjs:master.

@rschristian rschristian mentioned this pull request May 26, 2023
@Scott-Fischer Scott-Fischer changed the title Adds missing react types to compat Adds missing Context and Dispatch types to compat May 26, 2023
@Scott-Fischer Scott-Fischer marked this pull request as ready for review May 26, 2023 16:34
Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

@rschristian rschristian merged commit 9aca7f4 into preactjs:master May 26, 2023
JoviDeCroock added a commit that referenced this pull request Jan 24, 2024
JoviDeCroock added a commit that referenced this pull request Jan 24, 2024
JoviDeCroock added a commit that referenced this pull request Jan 24, 2024
* backport #4016

* backport #3996

* backport #4017

* backport #4019

* backport #4020

* backport #4026

* backport #4028
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing types for Dispatch and Context in the React namespace
4 participants