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

Icon Typing is not Compatible with Svelte 5 #201

Open
BOJIT opened this issue Dec 27, 2024 · 1 comment · May be fixed by #203
Open

Icon Typing is not Compatible with Svelte 5 #201

BOJIT opened this issue Dec 27, 2024 · 1 comment · May be fixed by #203

Comments

@BOJIT
Copy link

BOJIT commented Dec 27, 2024

Hi,

With the update to Svelte 5, the type signature for base Svelte components is a function rather than a class. See this paragraph for details.

This means that when trying to pass Carbon Icons as a prop/field in an object, they cannot be typed correctly, as the Carbon icons extend from CarbonIcon which descends from the deprecated SvelteComponentTyped.

The suggested approach is to change the typing of each generated icon from:

export declare class ExampleIcon extends CarbonIcon {}

to

export declare const ExampleIcon: Component<CarbonIconProps>

This ensures that the correct typings are inferred.

Image

Not sure the best way of including this sort of typing. I've generally only used Svelte's automatic typing in the past.

Kind regards,
James

@metonym
Copy link
Collaborator

metonym commented Dec 27, 2024

Hello, thank you for reporting this, with a detailed repro and docs source.

I think it makes sense to move away from SvelteComponentTyped. I'll triage this and see if the const Component approach is backwards-compatible (it should be).

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 a pull request may close this issue.

2 participants