Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument of type 'IconDefinition' is not assignable to parameter of type 'IconDefinitionOrPack'

Tags:

I'm using Angular 6 angular-starter and fontawesome, followed here on how to install fa to ng.

In my .ts looks like this:

import { library, dom } from '@fortawesome/fontawesome-svg-core';
import { faInstagram } from '@fortawesome/free-brands-svg-icons/faInstagram';
import { faLink } from '@fortawesome/free-solid-svg-icons/faLink';

public ngOnInit() {
    library.add(faInstagram);
    library.add(faLink);
    dom.watch();
}

Then in .html:

<fa-icon [icon]="['fab', 'instagram']"></fa-icon>

It works perfectly fine except for free brands, @fortawesome/free-brands-svg-icons. On build (npm start) it produces error/warning Argument of type 'IconDefinition' is not assignable to parameter of type 'IconDefinitionOrPack'. 'IconDefinition' is not assignable to type 'IconPack'. signature is missing in type 'IconDefinition'. on the 92% build but actually the build appears to be successful and the instagram icon shows up but I'm bothered because a red line below the code appears.

Can someone figure it out?

My package.json

"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.6",
"@fortawesome/free-brands-svg-icons": "^5.4.2",
"@fortawesome/free-solid-svg-icons": "^5.4.1",
like image 393
user3856437 Avatar asked Oct 30 '18 14:10

user3856437


People also ask

What is @fortawesome?

Font Awesome is the Internet's icon library and toolkit, used by millions of designers, developers, and content creators. Start for Free Get $20 Off Pro.


1 Answers

I'll mention a case with regular icons. Hope a similar approach will help you. You can just import the icon and then typecast it from IconDefinitionOrPack to IconDefinition while adding it to the library in your module constructor.

import { faTimesCircle, faCheckCircle } from '@fortawesome/free-regular-svg-icons';

Then while adding it in library typecast it

  export class AppModule {
    constructor() {
      library.add(faTable);
      library.add(faChartArea);
      library.add(faTachometerAlt);
      library.add(faTimesCircle as IconDefinition);
      library.add(faCheckCircle as IconDefinition);
    }
  }

In HTML,

<div class="col-md-6">
   <fa-icon [icon]="['far', 'check-circle']"></fa-icon>
   <span>Tax Info</span>
</div>
like image 149
Shubhashish Shukla Avatar answered Nov 11 '22 14:11

Shubhashish Shukla