react icon indicating copy to clipboard operation
react copied to clipboard

Cannot find name 'dialog'

Open jsoneaday opened this issue 1 year ago • 2 comments

I am using Typescript together with React 19rc. It appears that the new dialog element has not been added to the @types/react. I did try and add a types.d.ts file with the Intrinsics def but that does nothing.

This is the entire source code but on the affected file itself, https://github.com/PacktPublishing/Full-Stack-React-TypeScript-and-Node-2nd-Edition/blob/chap5/Final/blog/client/src/common/components/modals/Modal.ts

jsoneaday avatar Sep 12 '24 22:09 jsoneaday

Hey, I noticed the same issue while working with React 19rc and TypeScript. It seems like the dialog element hasn’t been added to @types/react yet. One workaround that’s helped me is manually extending the IntrinsicElements in a types.d.ts file. Here’s a quick snippet that might help:

declare module 'react' { interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> { dialog?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>; } }

This should temporarily fix the TypeScript error for now until the types package is updated. I’m also looking into submitting a PR to address this. Let me know if this works for you!

Ravi80595 avatar Sep 14 '24 07:09 Ravi80595

This element is typed for 7 years now and works on minimal apps:

<dialog open />

Playground Link There's likely something else wrong. Does the same error occur when you just use div? Are you sure the right tsconfig with support for JSX is being used?

For us to be able to help, we'd need a minimal reproduction that we an clone. Or a TypeScript Playground

eps1lon avatar Sep 25 '24 17:09 eps1lon

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Dec 24 '24 18:12 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

github-actions[bot] avatar Dec 31 '24 19:12 github-actions[bot]