-
Notifications
You must be signed in to change notification settings - Fork 150
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
Argument of type 'IconPack' is not assignable to parameter of type 'IconDefinitionOrPack' #125
Comments
@ehujdur Can you also add your code, which leads to this error? |
I have this issue loading Regular Icons.
|
Can you mention versions of |
Do you use both |
Managed to reproduce it, investigating. |
So the issue seems to be that you ended up having two instances of Can you first try to open your |
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. |
Thanks for your help! |
I had the problem too, the solution was to add a missing import-statement. @import "~@fortawesome/fontawesome-free/css/regular.css";
@import "~@fortawesome/fontawesome-free/css/solid.css";
@import "~@fortawesome/fontawesome-free/css/fontawesome.css";
@import "~@fortawesome/fontawesome-free/css/brands.css"; // <- this one was missing |
Hey so running into this issue also. Been using Pro on an angular 7 project for months, no issues what so ever. Tried to load the package.json:
|
@caleuanhopkins Can you try to perform steps described in #125 (comment) to see if you have two instances of the |
@caleuanhopkins Something looks odd, e.g.: |
Ok apologies! 🤦♂ Using Yarn to install packages and noticed after I remove the have removed the incorrect package now from the |
Please check #125 (comment) for instructions how to diagnose and workaround this issue. |
Running into the issue mentioned above, my What I've done to get it to work is clear out lines 2549-2555 in my However, I can't keep having to do this after each npm install, especially when builds are built and deployed through CI. Since all my packs are the same version, why does the brands one have this extra dependency and it requires a different version of the EDIT: Turns out I didn't have |
@epstarr Explicitly specifying Your approach didn't work, because |
Removing the I of course don't use both, but I know that a new team mate may or may not have been fiddling around this. |
I had the same issue, but the cause of my issue was that my @fortawesome/free-brands-svg-icons package was one (1) version newer than the rest of the fontawesome packages |
Fixed issue by using IconDefinition
|
I've tried everything. Here's what is in my package.json:
Every time I run an 'npm install' I get multiple versions of "@fortawesome/fontawesome-common-types" so I get the error: Types of property 'iconName' are incompatible. If I hand edit the package-lock.json file and remove the duplicates everything works... but every time I run 'npm install' I have duplicates again. Can anyone please help? Our build script automatically runs 'npm install' so the build always fails. If it helps my node version is v16.14.0 and for npm I've tried versions 6, 7, and 8 with the same problem. |
if you remove the .lock file and run npm install, does it still cause duplicates? |
Yes, I still get duplicates if I delete the .lock file. |
It's not ideal but this solution did work for now. Thanks @launchdex ! |
Hey @mightykip, Sorry for the late response! I've rasied this problem upstream in FortAwesome/Font-Awesome#16592 (comment). To resolve it on your side (for now), please change I hope that my proposal will get accepted and we can finally resolve this type compatibility mess. I've also created #346, which I'm going to look into once I have a response to my proposal. |
We are implementing @devoto13's proposal (it's a good one!) and it will be available in 6.1.0. |
@robmadole Will this part of the proposal be implemented as well? It is crucial as otherwise, people will keep facing the same problem because
|
@devoto13 yes. I'll be deprecating those. I will also be pinning each of the icon packages (like 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. |
Ok @devoto13 both of those packages are now deprecated. Hopefully that will clean up the mess! Thanks again for helping us with this one. |
It also resolves FortAwesome#125 as there is now a clear rule for how to avoid type mess - make sure that versions of the Font Awesome packages are aligned. Now that Font Awesome 6 is stable, we make repository v6-first and only test v5 for compatibility. Fixes FortAwesome#351 Closes FortAwesome#125
Hi developer, I haver another other solution for this problem: ` library.add( |
I had to set the versions fixed to make it work. deleted package-lock and ran npm i again
|
With this change `angular-fontawesome` exposes more permissive variants of some types (`IconPrefix`, `IconName`, `IconLookup`, `IconDefinition` and `IconPack`) from the `fontawesome-svg-core`. These new types allow arbitrary string values as icon name and icon prefix while maintaining auto-completion for the core Font Awesome icons. Firstly, this makes it possible to define and use custom icons without any casts, thus implementing part of the FortAwesome#172 and addressing part of the FortAwesome#423 (Kit packages with custom icons). The documentation for custom icons is coming later in a separate PR. Secondly, this makes `angular-fontawesome` resilient to multiple instance of `fontawesome-common-types` packages, thus helps with issues like FortAwesome#125. The drawback of this change is that if a user makes a typo in a core icon name or an icon prefix it will no longer produce a compile-time error, but will throw a runtime error instead. However, this trade-off seems to be overall the best option. Considerations: 1. To keep type safety while supporting custom icons, we'll need to somehow extend the mentioned icon types. It was investigated in the FortAwesome#172 (comment). The conclusion is that it requires very convoluted code to be added to the project and therefore is undesired. 2. For the explicit reference approach, the type safety/completion is not really needed as icon definitions are imported as runtime symbols and importing a symbol which does not exist will always result in complication error. 3. For the icon library approach, the type safety isn't perfect either. While it will catch cases where one specifies a completely incorrect icon name, it does not catch all problems. Icons are added to the library at runtime and if an icon name is correct, but the icon was not added to the library it will still result in a runtime error.
With this change `angular-fontawesome` exposes more permissive variants of some types (`IconPrefix`, `IconName`, `IconLookup`, `IconDefinition` and `IconPack`) from the `fontawesome-svg-core`. These new types allow arbitrary string values as icon name and icon prefix while maintaining auto-completion for the core Font Awesome icons. Firstly, this makes it possible to define and use custom icons without any casts, thus implementing part of the FortAwesome#172 and addressing part of the FortAwesome#423 (Kit packages with custom icons). The documentation for custom icons is coming later in a separate PR. Secondly, this makes `angular-fontawesome` resilient to multiple instance of `fontawesome-common-types` packages, thus helps with issues like FortAwesome#125. The drawback of this change is that if a user makes a typo in a core icon name or an icon prefix it will no longer produce a compile-time error, but will throw a runtime error instead. However, this trade-off seems to be overall the best option. Considerations: 1. To keep type safety while supporting custom icons, we'll need to somehow extend the mentioned icon types. It was investigated in the FortAwesome#172 (comment). The conclusion is that it requires very convoluted code to be added to the project and therefore is undesired. 2. For the explicit reference approach, the type safety/completion is not really needed as icon definitions are imported as runtime symbols and importing a symbol which does not exist will always result in complication error. 3. For the icon library approach, the type safety isn't perfect either. While it will catch cases where one specifies a completely incorrect icon name, it does not catch all problems. Icons are added to the library at runtime and if an icon name is correct, but the icon was not added to the library it will still result in a runtime error.
With this change `angular-fontawesome` exposes more permissive variants of some types (`IconPrefix`, `IconName`, `IconLookup`, `IconDefinition` and `IconPack`) from the `fontawesome-svg-core`. These new types allow arbitrary string values as icon name and icon prefix while maintaining auto-completion for the core Font Awesome icons. Firstly, this makes it possible to define and use custom icons without any casts, thus implementing part of the #172 and addressing part of the #423 (Kit packages with custom icons). The documentation for custom icons is coming later in a separate PR. Secondly, this makes `angular-fontawesome` resilient to multiple instance of `fontawesome-common-types` packages, thus helps with issues like #125. The drawback of this change is that if a user makes a typo in a core icon name or an icon prefix it will no longer produce a compile-time error, but will throw a runtime error instead. However, this trade-off seems to be overall the best option. Considerations: 1. To keep type safety while supporting custom icons, we'll need to somehow extend the mentioned icon types. It was investigated in the #172 (comment). The conclusion is that it requires very convoluted code to be added to the project and therefore is undesired. 2. For the explicit reference approach, the type safety/completion is not really needed as icon definitions are imported as runtime symbols and importing a symbol which does not exist will always result in complication error. 3. For the icon library approach, the type safety isn't perfect either. While it will catch cases where one specifies a completely incorrect icon name, it does not catch all problems. Icons are added to the library at runtime and if an icon name is correct, but the icon was not added to the library it will still result in a runtime error.
Worked like a charm. Thanks. |
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
The text was updated successfully, but these errors were encountered: