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

Migrate generated Svelte icons from SvelteComponentTyped to SvelteComponent #1507

Closed
EdricChan03 opened this issue Aug 15, 2023 · 2 comments · Fixed by #1517
Closed

Migrate generated Svelte icons from SvelteComponentTyped to SvelteComponent #1507

EdricChan03 opened this issue Aug 15, 2023 · 2 comments · Fixed by #1517
Labels
🐛 bug Something isn't working

Comments

@EdricChan03
Copy link

EdricChan03 commented Aug 15, 2023

Prerequisites

  • Version: 0.268.0
  • Are you running from source/main: no
  • Are you using a released build: yes
  • Operating system: macOS 12.6.5
  • Bits: 64-bit

Step to reproduce

  1. Try to copy an existing icon's base type definition:

    import type { SvelteComponentTyped } from 'svelte';
    import { type IconProps, type IconEvents, Link2Icon } from 'lucide-svelte';
    
    const data: { example: string, icon: SvelteComponentTyped<IconProps, IconEvents, {}>, /* ... */ }[] = [
      { example: 'abc', icon: Link2Icon }, /* ... */
    ]
  2. Note the deprecation from SvelteComponentTyped, with the following message:

    @deprecated Use SvelteComponent instead. See PR for more information: breaking: deprecate SvelteComponentTyped, add generics to SvelteComponent sveltejs/svelte#8512

  3. Attempt to use SvelteComponent instead:

    -import type { SvelteComponentTyped } from 'svelte';
    +import type { SvelteComponent } from 'svelte';
    -{ example: string, icon: SvelteComponentTyped<IconProps, IconEvents, {}>, /* ... */ }
    +{ example: string, icon: SvelteComponent<IconProps, IconEvents, {}>, /* ... */ }

Actual behavior

A TypeScript error is outputted as a result of performing step 3.

Any message or error

Type 'typeof Link2Icon' is missing the following properties from type 'SvelteComponent<IconProps, IconEvents, {}>': $$prop_def, $$events_def, $$slot_def, $capture_state, and 6 more.ts(2740)

Resources

EDIT: I see that this was noted here as well: #1388 (comment)


On an unrelated note, could a TypeScript type that all icons can extend from be added as well? Perhaps something like the following:

export type LucideIconComponent = SvelteComponent<IconProps, IconEvents, {}>;
@EdricChan03 EdricChan03 added the 🐛 bug Something isn't working label Aug 15, 2023
@EdricChan03
Copy link
Author

On second thought, the same error also appears to happen with SvelteComponentTyped

@JanTrichter
Copy link
Contributor

JanTrichter commented Aug 17, 2023

Thanks for reporting! Couldn't find the error that you reported though as I can build it without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants