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

Form-data 5.0.0 types no longer compatible with node-fetch 3.2.1 #60

Closed
Nkmol opened this issue Oct 28, 2022 · 2 comments
Closed

Form-data 5.0.0 types no longer compatible with node-fetch 3.2.1 #60

Nkmol opened this issue Oct 28, 2022 · 2 comments

Comments

@Nkmol
Copy link

Nkmol commented Oct 28, 2022

Contrary to the readme, the FormData object is no longer type-compatible with the body parameter of node-fetch 3.2.1.

Type 'FormData' is not assignable to type 'BodyInit | null | undefined'.
Type 'import("/Users/sandermol/www/tpg/devops/monitor/server/scraper/docker/node/node_modules/formdata-node/@type/FormData", { assert: { "resolution-mode": "import" } }).FormData' is not assignable to type 'FormData'.
The types returned by 'get(...)' are incompatible between these types.
Type 'import("/Users/sandermol/www/tpg/devops/monitor/server/scraper/docker/node/node_modules/formdata-node/@type/FormData", { assert: { "resolution-mode": "import" } }).FormDataEntryValue | null' is not assignable to type 'FormDataEntryValue | null'.
Type 'File' is not assignable to type 'FormDataEntryValue | null'.
Type 'import("/Users/sandermol/www/tpg/devops/monitor/server/scraper/docker/node/node_modules/formdata-node/@type/File", { assert: { "resolution-mode": "import" } }).File' is not assignable to type 'File'.
The types returned by 'slice(...).stream()' are incompatible between these types.
Type 'ReadableStream' is missing the following properties from type 'ReadableStream': readable, read, setEncoding, pause, and 21 more.ts(2322)

    const form = new FormData();
    form.set('grant_type', 'client_credentials');

    const request = await fetch('https://xxxx', {
      method: 'POST',
      body: form,
    });

Workaround is using the form-data-encoder.

@octet-stream
Copy link
Owner

octet-stream commented Oct 28, 2022

Duplicate of #57

Hi, thank you for reaching me out with this issue. I'm not sure why is this happening, but it seem like TS maps ReadableStream to NodeJS.ReadableStream an I don't understand why.

Please, keep further discussion by the issue I mentioned.

@octet-stream octet-stream closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2022
@octet-stream
Copy link
Owner

v6 is released and should be compatible with node-fetch BodyInit type (tested with node-fetch v3.3.2 on TypeScript 5.2.2), check out release notes for more information: https://github.com/octet-stream/form-data/releases/tag/v6.0.0

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

No branches or pull requests

2 participants