Font-awesome: npm install index.d.ts incorrect typings prevents use with typescript

Created on 18 Jan 2018  路  9Comments  路  Source: FortAwesome/Font-Awesome

package.json

...
    "@fortawesome/fontawesome": "^1.1.2",
    "@fortawesome/fontawesome-free-brands": "^5.0.4",
    "@fortawesome/fontawesome-free-regular": "^5.0.4",
    "@fortawesome/fontawesome-free-solid": "^5.0.4",
...

index.d.ts

export interface DOM {
  i2svg(params: { node: Node; callback: () => void }): void;
  css(): string;
  insertCss(): string;
}

because i2svg takes a non optional params object I can't call it fontawsome.dom.i2svg() as typescript compiler rightly complains.

if you change i2svg(params: { node: Node; callback: () => void }): void; css(): string; to i2svg(params?: { node: Node; callback: () => void }): void; css(): string; it seems to work.

bug svg waiting for feedback

Most helpful comment

Hi @robmadole @mlwilkerson
Any progress on this issue? I got some similar problems when using this in my TS project. :-(
Regards
Martin

All 9 comments

@robmadole could you please check this?

Are you the right person to deal with typescript issues or there is someone else in the team?

Hey @tagliala I'll throw this one to @mlwilkerson. He's the TS SME.

Any progress on this issue? It's preventing me to use in my Typescript project as well

No update yet. We'll get to it as soon as we can.

Hi @robmadole @mlwilkerson
Any progress on this issue? I got some similar problems when using this in my TS project. :-(
Regards
Martin

Ok we鈥檝e got the simple fix in a PR in our build system and aim to have this out as part of the 5.1 prereleases

For anyone else running into this that is as unfamiliar with TypeScript as me, I muddled around and managed to get this working by merging a new, correct declaration in locally just before the call to i2svg:

declare module "@fortawesome/fontawesome" {
    interface DOM {
        i2svg(params?: { node?: Node; callback?: () => void }): void;
    }
}

Thanks for the clean-up hint @tomyam1 :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eschwinm picture Eschwinm  路  3Comments

daneren2005 picture daneren2005  路  3Comments

huuphat picture huuphat  路  3Comments

brystfire08 picture brystfire08  路  3Comments

douglasdeodato picture douglasdeodato  路  3Comments