Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with building app with fusionauth-typescript-client #59

Open
Ilchuk-Mihail opened this issue Sep 16, 2021 · 6 comments
Open

Issues with building app with fusionauth-typescript-client #59

Ilchuk-Mihail opened this issue Sep 16, 2021 · 6 comments

Comments

@Ilchuk-Mihail
Copy link

Ilchuk-Mihail commented Sep 16, 2021

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 ?

@mooreds
Copy link
Contributor

mooreds commented Sep 21, 2021

Thanks for the bug report. Will take a look in the next few days.

@koshkarov
Copy link

Same issue with 1.30.2.

@ocean-rey
Copy link

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.

@Ilchuk-Mihail
Copy link
Author

Ilchuk-Mihail commented Nov 17, 2021

@ocean-rey You could also try adding "@types/node-fetch": "^2.5.7" to your dev/dependencies.

@ocean-rey
Copy link

@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?

@Ilchuk-Mihail
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants