Skip to content

Bug: Rendering a variable in jsx within a functional component that is a bigint throws type error #24716

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

Closed
ByronBecker opened this issue Jun 13, 2022 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@ByronBecker
Copy link

React (and ReactDOM) version: "^18.1.0"
TypeScript version: "^4.7.3",

Steps To Reproduce

  1. Create this component in a typescript + react + react-dom application
function myComponent(score: bigint) {
  return <>
    <div>score: {score} </div>
  </>
}
  1. See the ``TS2746: This JSX tag's 'children' prop expects a single child of type 'ReactNode', but multiple children were provided.` error.

Link to code example:

The current behavior

Throws type error. Converting the bigint -> string via .toString() removes the error

The expected behavior

Should not throw an error

@ByronBecker ByronBecker added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Jun 13, 2022
@liwenkang
Copy link

liwenkang commented Jun 13, 2022

// node_modules/@types/react/index.d.ts
type ReactNode = ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined;

in react types file, you can see the bigint is not an option for ReactNode.

@ByronBecker
Copy link
Author

@liwenkang Right, but it should then throw a more informative error - not "multiple children were provided"

@eps1lon
Copy link
Collaborator

eps1lon commented Jun 13, 2022

@liwenkang Right, but it should then throw a more informative error - not "multiple children were provided"

We can't do anything about that unfortunately. You would need to file that against https://github.com/microsoft/typescript

For bigint support see #20492

@eps1lon eps1lon closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2022
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

3 participants