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

Cannot find name 'dialog' #30953

Open
jsoneaday opened this issue Sep 12, 2024 · 2 comments
Open

Cannot find name 'dialog' #30953

jsoneaday opened this issue Sep 12, 2024 · 2 comments

Comments

@jsoneaday
Copy link

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

@Ravi80595
Copy link

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 extends AriaAttributes, DOMAttributes {
dialog?: React.DetailedHTMLProps<React.HTMLAttributes, 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!

@eps1lon
Copy link
Collaborator

eps1lon commented Sep 25, 2024

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 eps1lon changed the title [React 19] Cannot find name 'dialog' Cannot find name 'dialog' Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@jsoneaday @eps1lon @Ravi80595 and others