angular-fontawesome: Argument of type 'IconPack' is not assignable to parameter of type 'IconDefinitionOrPack'
Describe the problem
Trying to import fab icons to angular project, but cli says there’s the following error:
error TS2345: Argument of type 'IconPack' is not assignable to parameter of type 'IconDefinitionOrPack'. Type 'IconPack' is missing the following properties from type 'IconDefinition': icon, prefix, iconName
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 34 (3 by maintainers)
Links to this issue
Commits related to this issue
- Allow fontawesome-svg-core ^6.1.0 as a valid peer dependency It also resolves #125 as there is now a clear rule for how to avoid type mess - make sure that versions of the Font Awesome packages are a... — committed to devoto13/angular-fontawesome by devoto13 2 years ago
- Allow fontawesome-svg-core ^6.1.0 as a valid peer dependency It also resolves #125 as there is now a clear rule for how to avoid type mess - make sure that versions of the Font Awesome packages are a... — committed to FortAwesome/angular-fontawesome by devoto13 2 years ago
- Introduce more permissive icon types With this change `angular-fontawesome` exposes more permissive variants of some types (`IconPrefix`, `IconName`, `IconLookup`, `IconDefinition` and `IconPack`) fr... — committed to devoto13/angular-fontawesome by devoto13 3 years ago
- Introduce more permissive icon types With this change `angular-fontawesome` exposes more permissive variants of some types (`IconPrefix`, `IconName`, `IconLookup`, `IconDefinition` and `IconPack`) fr... — committed to devoto13/angular-fontawesome by devoto13 3 years ago
- Introduce more permissive icon types With this change `angular-fontawesome` exposes more permissive variants of some types (`IconPrefix`, `IconName`, `IconLookup`, `IconDefinition` and `IconPack`) fr... — committed to FortAwesome/angular-fontawesome by devoto13 3 years ago
I had the problem too, the solution was to add a missing import-statement.
Fixed issue by using IconDefinition
So the issue seems to be that you ended up having two instances of
@fortawesome/fontawesome-common-types
of different versions installed.Can you first try to open your
package-lock.json
/yarn.lock
and search for"@fortawesome/fontawesome-common-types": {
? Does it find more than one result? If so try changing@fortawesome/fontawesome-svg-core
to^1.2.12
and runningnpm install
to force it to update and de-duplicate?Hi developer, I haver another other solution for this problem:
` import { fas } from ‘@fortawesome/free-solid-svg-icons’ import { fab } from ‘@fortawesome/free-brands-svg-icons’ import { far } from ‘@fortawesome/free-regular-svg-icons’ import { library, IconPack } from ‘@fortawesome/fontawesome-svg-core’
library.add( far as IconPack, fas as IconPack, fab as IconPack ) `
Hey @mightykip, Sorry for the late response!
I’ve rasied this problem upstream in https://github.com/FortAwesome/Font-Awesome/issues/16592#issuecomment-1053578571. To resolve it on your side (for now), please change
"@fortawesome/fontawesome-svg-core": "^1.3.0"
to"@fortawesome/fontawesome-svg-core": "~1.2.36"
andnpm install
.I hope that my proposal will get accepted and we can finally resolve this type compatibility mess.
I’ve also created https://github.com/FortAwesome/angular-fontawesome/issues/346, which I’m going to look into once I have a response to my proposal.
I couldn’t get it to force the install, so I removed it from packages.json and then readded it. Now all point to ^0.2.15. (While before one was pointing to 0.2.12)
So the better question, is this an NPM issue or a deployment problem from the package?
It’s is a consequence of how FontAwesome packages are structured. Let’s keep this issue open, I’lll think how we can prevent this from happening in the future.
Ok @devoto13 both of those packages are now deprecated. Hopefully that will clean up the mess! Thanks again for helping us with this one.
@devoto13 yes. I’ll be deprecating those. I will also be pinning each of the icon packages (like
@fortawesome/free-solid-svg-icons
) to use@fortawesome/fontawesome-svg-core
at6.1.0
instead of^6.1.0
. It just doesn’t make sense to let that dependency be out of sync with the exact version of the icon packages.I think at one point we thought it might be useful to release these things with patch releases outside the normal Font Awesome release process. But that idea hasn’t panned out (we’ve never done that to my knowledge.) So it makes sense to just keep all these version grouped together and all dependencies will match.
It’s not ideal but this solution did work for now.
Thanks @launchdex !
Managed to reproduce it, investigating.
I had to set the versions fixed to make it work. deleted package-lock and ran npm i again
We are implementing @devoto13’s proposal (it’s a good one!) and it will be available in 6.1.0.
Ok apologies! 🤦♂
Using Yarn to install packages and noticed after I remove the
package-lock.json
that yarn has it’s ownlock.json
file and yes I can see more than 1@fortawesome/fontawesome-common-types
package.have removed the incorrect package now from the
yarn.lock
, reinstallednode_modules
and is working now 👍