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

Bug: JSX SVG Typescript type error: missing 'slot' attribute #32406

Open
apprat opened this issue Feb 17, 2025 · 10 comments
Open

Bug: JSX SVG Typescript type error: missing 'slot' attribute #32406

apprat opened this issue Feb 17, 2025 · 10 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@apprat
Copy link

apprat commented Feb 17, 2025

Image

@apprat apprat added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Feb 17, 2025
@dineshkolhe1
Copy link

Can you give a brief explanation to your issue ! Exactly what you want to say

@apprat
Copy link
Author

apprat commented Feb 17, 2025

Can you give a brief explanation to your issue ! Exactly what you want to say

The SVG lacks the attribute 'slot' in the Typescript type of JSX, which exists in SVGElement.

@dineshkolhe1
Copy link

@apprat
This issue occurs because TypeScript’s JSX type definitions (React.SVGProps) do not include slot as a valid attribute, even though slot exists in the DOM definition for SVGElement.

@julianandresr199
Copy link

#32406

@Cindyband
Copy link

Yes JavaScript and yes windows 11 and search engine bing

@Cindyband
Copy link

to gitgub

@Nipz66
Copy link

Nipz66 commented Feb 18, 2025

TypeScript's JSX type definitions don't include a slot for SVGElement, even though it's valid in the DOM. A workaround is to use type assertion: <svg {...({ slot: 'start' } as any)}> or extend React.SVGProps to include slot. I hope this helps!🙄

@apprat
Copy link
Author

apprat commented Feb 18, 2025

TypeScript's JSX type definitions don't include a slot for SVGElement, even though it's valid in the DOM. A workaround is to use type assertion: <svg {...({ slot: 'start' } as any)}> or extend React.SVGProps to include slot. I hope this helps!🙄TypeScript 的 JSX 类型定义不包含 SVGElement 的插槽,即使它在 DOM 中有效。解决方法是使用类型断言:<svg {...({ slot: 'start' } as any)}> 或扩展 React.SVGProps 以包含 slot。我希望这有帮助! 🙄

This is too ugly. I hope type definitions can be added to the official repository.

@dineshkolhe1
Copy link

TypeScript's JSX type definitions don't include a slot for SVGElement, even though it's valid in the DOM. A workaround is to use type assertion: <svg {...({ slot: 'start' } as any)}> or extend React.SVGProps to include slot. I hope this helps!🙄

@Nipz66
but <svg {...({ slot: 'start' } as any)}> . This fixes the error, but it removes type safety, which is not ideal.

@Nipz66
Copy link

Nipz66 commented Feb 18, 2025

Oo, It is not ideal.

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

5 participants