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

fix(types): add key to IntrinsicAttributes #3474

Merged
merged 2 commits into from
Oct 2, 2024
Merged

Conversation

codehz
Copy link
Contributor

@codehz codehz commented Oct 1, 2024

make arr.map(x => <CustomComponent key={x.id} />) not emit type error

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@codehz codehz changed the title add key to IntrinsicAttributes fix(types): add key to IntrinsicAttributes Oct 1, 2024
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.58%. Comparing base (c0d782c) to head (4389bd1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3474   +/-   ##
=======================================
  Coverage   95.58%   95.58%           
=======================================
  Files         155      155           
  Lines        9357     9357           
  Branches     2735     2752   +17     
=======================================
  Hits         8944     8944           
  Misses        413      413           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yusukebe
Copy link
Member

yusukebe commented Oct 1, 2024

Hi @codehz

Thank you for the PR.

I just wanted to confirm it with you. Currently, it does not throw a type error on my machine. Is this what you're pointing out?

CleanShot 2024-10-01 at 18 21 59@2x

@codehz
Copy link
Contributor Author

codehz commented Oct 1, 2024

Hi @codehz

Thank you for the PR.

I just wanted to confirm it with you. Currently, it does not throw a type error on my machine. Is this what you're pointing out?

CleanShot 2024-10-01 at 18 21 59@2x

while in my machine
image

and the Window is defined as

function Window({
  id,
  title,
  state,
  zIndex,
}: {
  id: WindowId;
  title: WindowTitleState;
  state: WindowState;
  zIndex: number;
}) {...
}

@codehz
Copy link
Contributor Author

codehz commented Oct 1, 2024

@yusukebe post in typescript playground

Playground Link

@yusukebe
Copy link
Member

yusukebe commented Oct 2, 2024

Thanks @codehz !

Indeed, if we treat hono/jsx as the same as React, we should add the key attribute.

Initially, hono/jsx was developed as non-React JSX, which does not support key. If we follow that policy, we can't accept this PR. However, currently, we are saying "hono/jsx has (almost) compatibility for React." So, it may be okay to add the key attribute.

@usualoma, what do you think of this?

@usualoma
Copy link
Member

usualoma commented Oct 2, 2024

Hi @codehz. Thank you!

@yusukebe Compatibility with React is important now, and this addition does not affect the function for stringification, so I agree with the merge!

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Oct 2, 2024

@usualoma Thank you for the comment.

@codehz Looks good. I'll merge this now. Thank you.

@yusukebe yusukebe merged commit 31b4cd4 into honojs:main Oct 2, 2024
16 checks passed
@codehz codehz deleted the patch-2 branch October 7, 2024 10:34
TinsFox pushed a commit to TinsFox/hono that referenced this pull request Oct 28, 2024
* add key to IntrinsicAttributes

* fix format error
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.

3 participants