question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@fortawesome/Angular-FontAwesome doesn't work within an Angular 6 Library

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
devoto13commented, Jul 2, 2018

IIRC it is a TypeScript limitation, when emitting d.ts files (i.e. declaration: true is set in the tsconfig.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.

1reaction
learnuser521commented, Nov 26, 2018

@devoto13 I have not yet updated to Angular 7, will get back if there are issues after the update. Thank you

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found