@fortawesome/Angular-FontAwesome doesn't work within an Angular 6 Library
See original GitHub issueI am trying to run the Explicit reference code example within an Angular 6 library. It doesn’t compile and here are the build errors.
projects/test-lib/src/lib/font-test/font-test.component.ts(11,3): error TS4029: Public property 'faCoffee' of exported class has or is using name 'IconDefinition' from external module "c:/git/test-app/node_modules/@fortawesome/fontawesome-common-types/index" but cannot be named.
Error: projects/test-lib/src/lib/font-test/font-test.component.ts(11,3): error TS4029: Public property 'faCoffee' of exported class has or is using name 'IconDefinition' from external module "c:/git/test-app/node_modules/@fortawesome/fontawesome-common-types/index" but cannot be named.
at Object.<anonymous> (c:\git\test-app\node_modules\ng-packagr\lib\ngc\compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at fulfilled (c:\git\test-app\node_modules\ng-packagr\lib\ngc\compile-source-files.js:4:58)
at <anonymous>
Please note that it works for an application but not a library. The library is generated using the following command:
ng new test-app
cd test-app
ng generate library test-lib
Thanks
-Rushui
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Angular - FontAwesome Dependencies missing error
It looks like something is messed up with node_modules or Angular CLI cache. Try removing node_modules and dist folder and re-running npm ...
Read more >@fortawesome/angular-fontawesome - npm
Angular Fontawesome, an Angular library. ... Start using @fortawesome/angular-fontawesome in your project by running `npm i ...
Read more >How To Use Font Awesome icons in Angular Applications
In this tutorial I will explain how to use Font Awesome icons in Angular applications using @fortawesome/angular-fontawesome package.
Read more >Angular | Font Awesome Docs
On This Page. Documentation. Font Awesome now has an official Angular component that's available for all who want to to easily use our...
Read more >FA-ICON problems in Angular Library Projects : Root Causes ...
Angular Libraries (6 Part Series) · Make sure the library has run these commands. npm i @fortawesome/angular-fontawesome // and any peer ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
IIRC it is a TypeScript limitation, when emitting d.ts files (i.e.
declaration: true
is set in thetsconfig.json
). https://github.com/Microsoft/TypeScript/issues/5711 is a relevant issue. I don’t think anything is broken in the FA library, it’s just how TypeScript works.The workaround is to add explicit type annotation to the property (which in turn ensures that there is an import statement for the required type). E.g.
class MyComponent { faCoffee: IconDefinition = faCoffee }
. See linked issue for more reasoning on why it is needed.PS Looks like the issue was fixed in TypeScript 2.9.1, so just need to wait until Angular adds support for this version.
@devoto13 I have not yet updated to Angular 7, will get back if there are issues after the update. Thank you