Issues with building app with fusionauth-typescript-client
When I try to build app tsc --build with lib installed, I get an error like this:
node_modules/@fusionauth/typescript-client/build/src/IRESTClient.d.ts:3:46 - error TS7016: Could not find a declaration file for module 'node-fetch'. '/Users/.../node_modules/@fusionauth/typescript-client/node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`
import { RequestCredentials, Response } from "node-fetch";
node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.d.ts:3:36 - error TS7016: Could not find a declaration file for module 'node-fetch'. '/Users/.../node_modules/@fusionauth/typescript-client/node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`
import { RequestCredentials } from "node-fetch";
Typescript and lib versions:
- typescript 4.3.5
- @fusionauth/typescript-client: 1.30.0
The quick fix is to add "@types/node-fetch": "^2.5.7" to dependencies.
Current version of node-fetch already contains types but, there is no such type like RequestCredentials.
Is there any other fix ? or is it possible to update node-fetch here to the latest one ?
Thanks for the bug report. Will take a look in the next few days.
Same issue with 1.30.2.
for anyone else coming here from a google search, here's how i got it "working" in my project:
install node package patch-package
npm install --save patch-package
in your package.json file add the following script to the "scripts" block
"postinstall": "patch-package"
in /node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.d.ts:
add
//@ts-ignore right above
import { RequestCredentials } from "node-fetch";
repeat in /node_modules/@fusionauth/typescript-client/build/src/IRESTClient.d.ts for
import { RequestCredentials, Response } from "node-fetch";
after saving your changes, in your project root run
npx patch-package @fusionauth/typescript-client
and voila.
this is really more of a band-aid rather than a proper fix but if you need to go live asap this seems to work.
@ocean-rey You could also try adding "@types/node-fetch": "^2.5.7" to your dev/dependencies.
@ocean-rey You could also try adding
"@types/node-fetch": "^2.5.7"to your dev/dependencies.
I did try this but it didn't seem to work for me; perhaps i'm doing something wrong?
For me tsc --build didn't work (errors at the first comment), but when I installed that package to devDependencies, the build works. (So just adding this and reinstall packages works for me)