fix(types): loosen icon prop type to any (#2095)

Fixes https://github.com/carbon-design-system/carbon-icons-svelte/issues/207

`carbon-icons-svelte@13` and `carbon-pictograms-svelte@13` now  
only support TypeScript for Svelte 4/5.

The new `Component` type is incompatible with the `icon` prop in  
`carbon-components-svelte`, causing a type error with Svelte 5, as  
`typeof SvelteComponent` doesn't match the new `Component` type.

Since `Component` isn't available in Svelte 3/4, this PR changes  
the `icon` prop type to `any` for compatibility across Svelte 3, 4, and 5.
This commit is contained in:
Eric Liu 2025-02-02 19:49:53 -08:00 committed by GitHub
commit 6bf72d4602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 273 additions and 251 deletions

View file

@ -624,7 +624,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render\nAlternatively, use the named slot \"icon\" (e.g., `<Icon slot=\"icon\" size=\"{20}\" />`)",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -2570,7 +2570,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render\nIcon is rendered to the left of the label text",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -5771,7 +5771,7 @@
"name": "iconMenu",
"kind": "let",
"description": "Specify the icon to render for the closed state.\nDefaults to `<Menu size={20} />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -5782,7 +5782,7 @@
"name": "iconClose",
"kind": "let",
"description": "Specify the icon to render for the opened state.\nDefaults to `<Close size={20} />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -5849,7 +5849,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render when the action panel is closed.\nDefaults to `<Switcher size={20} />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -5860,7 +5860,7 @@
"name": "closeIcon",
"kind": "let",
"description": "Specify the icon to render when the action panel is open.\nDefaults to `<Close size={20} />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -5996,7 +5996,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -6059,7 +6059,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -7007,7 +7007,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render\n`inline` must be `false`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -7987,7 +7987,7 @@
"name": "primaryButtonIcon",
"kind": "let",
"description": "Specify the primary button icon",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -8228,7 +8228,7 @@
"name": "primaryButtonIcon",
"kind": "let",
"description": "Specify the primary button icon",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -9000,7 +9000,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -9712,7 +9712,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render.\nDefaults to `<OverflowMenuVertical />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -12032,7 +12032,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render.\nDefaults to `<Search />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -12974,7 +12974,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -13054,7 +13054,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -15061,7 +15061,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -17297,7 +17297,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render for the tooltip button.\nDefault to `<Information />`",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -17646,7 +17646,7 @@
"name": "icon",
"kind": "let",
"description": "Specify the icon to render",
"type": "typeof import(\"svelte\").SvelteComponent<any>",
"type": "any",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
@ -17956,9 +17956,9 @@
"ts": "type TreeNodeId = string | number;\n"
},
{
"type": "{ id: TreeNodeId; text: any; icon?: typeof import(\"svelte\").SvelteComponent<any>; disabled?: boolean; nodes?: TreeNode[]; }",
"type": "{ id: TreeNodeId; text: any; icon?: any; disabled?: boolean; nodes?: TreeNode[]; }",
"name": "TreeNode",
"ts": "interface TreeNode {\n id: TreeNodeId;\n text: any;\n icon?: typeof import(\"svelte\").SvelteComponent<any>;\n disabled?: boolean;\n nodes?: TreeNode[];\n}\n"
"ts": "interface TreeNode {\n id: TreeNodeId;\n text: any;\n icon?: any;\n disabled?: boolean;\n nodes?: TreeNode[];\n}\n"
}
],
"generics": null,