You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, I'm using @fortawesome/pro-duotone-svg-icons and @fortawesome/pro-duotone-svg-icons, which type exported icons as: type IconDefinition = { IconPrefix: 'far' | 'fad' | 'all-other-prefixes', ... }.
The "bug" is that each package should type the IconPrefix of its exports to only the prefix(es) supported by that package.
For example: @fortawesome/pro-duotone-svg-icons would export icons as type IconDefinition = { IconPrefix: 'fad', ... } explicitly, allowing compile-time checking of the icon class used.
I've tried using type declarations to override this typing, but it seems .d.ts files can only extend, not override types; so the only workaround would be to patch the package or perform a runtime check.
I would be happy to submit a PR for this myself but I'm unsure how as this affects Pro packs.
Font Awesome version
v6.6.0
Application and Operating System
TypeScript 5.4.5
Web bug report checklist
I have included a test case because my odds go way up that the team can fix this when I do
Looking at the free-regular-svg-icons typing, it seems this could be tricky/hacky without converting some of the fontawesome-common-types types to generics, as all icons across all packs are typed as the same IconDefinition. IconDefinition could be updated to type IconDefinition<T extends IconPrefix> = { prefix: T, ... }, but this would be a breaking change for consumers of @fort-awesome/fontawesome-common-types/IconDefinition
This could be done per package (without breaking common-types) by modifying IconDefinition:
Bug description
Hi all, I'm using
@fortawesome/pro-duotone-svg-icons
and@fortawesome/pro-duotone-svg-icons
, which type exported icons as:type IconDefinition = { IconPrefix: 'far' | 'fad' | 'all-other-prefixes', ... }
.The "bug" is that each package should type the IconPrefix of its exports to only the prefix(es) supported by that package.
For example:
@fortawesome/pro-duotone-svg-icons
would export icons astype IconDefinition = { IconPrefix: 'fad', ... }
explicitly, allowing compile-time checking of the icon class used.I've tried using type declarations to override this typing, but it seems .d.ts files can only extend, not override types; so the only workaround would be to patch the package or perform a runtime check.
I would be happy to submit a PR for this myself but I'm unsure how as this affects Pro packs.
Font Awesome version
v6.6.0
Application and Operating System
Web bug report checklist
The text was updated successfully, but these errors were encountered: