Open Mukhametvaleev opened 5 years ago
@Mukhametvaleev can you provide a reproduction using something like codesandbox.io? It's too difficult to debug this with just partial examples.
I have the same problem :( implement in typescript
@Mukhametvaleev, did you find a solution to this problem? I am struggling with it too
@Mukhametvaleev, did you find a solution to this problem? I am struggling with it too
Unfortunately not, I'll try to reproduce this problem again
i have this problem too, my workaround right now is to do this
import { library } from "@fortawesome/fontawesome-svg-core";
const myLibrary: any = library;
myLibrary.add(fab, faCheckSquare, faCoffee);
(Please check that you have dependencies updated before continuing)
TS devs can we get some help? We have this defined here but it seems not to work? Again, can someone help to reproduce this? We have a test in our build system that confirms this works so it has to be a situational/configuration issue.
@robmadole I'll try to make a sandbox when I have some time, maybe tomorrow.
Hi @robmadole, I made a minimum repository to reproduce the problem and a codesandbox too. But it seems the error occurs only running locally, I have no idea why.
https://efbom.sse.codesandbox.io/ >>> sandbox (here it's fine) https://github.com/TiagoFuelber/font-awesome-typescript-error-sandbox >>> repo (git clone, npm i, npm start, and the errors pop in the console)
Hey all, I looked over @TiagoFuelber GitHub repo example and I have no clue why this isn't working. We have the TS definitions. I can't see any problems. This one is going to be beyond us because we don't use TypeScript. If anyone can offer help and explain why it's broken we'll try and get it fixed. But at this point 🤷♂
Hi @robmadole & @TiagoFuelber I ran into this issue and I believe I've solved it (it works in my project and it works on @TiagoFuelber 's test repo).
Make sure to have "moduleResolution": "node",
in your tsconfig.json
. That's it, not an issue with Fo(r/n)tAwesome.
Longer explaination (disclaimer: I'm no react expert and only just started messing around with TS):
"Property 'add' does not exist on type 'Library'." is slightly misleading as the real issue is the types are not being loaded at all. As far as I can tell, without "moduleResolution": "node",
in your tsconfig.json
, TS by default will only look in node_modules/@types
for type definitions, so any modules like @fortawesome/fontawesome-svg-core that have their types declared in the module (as opposed to a separate @types package) will not resolve as expected. I noticed this in my project because my other packages which also included their type definitions in their main package had the same issue, but all type definitions from @types/*
packages were resolving fine.
Anyways, hope that helps!
Hello! I can't manage to build a Library, webpack build fails with:
retrieve.ts:
Packages installed via yarn:
I have tried both
stable
andprerelease
versions of@fortawesome
packages.Wepback config: