Closed
Description
The iterator type for FormDataLike is incorrect / too restrictive (
form-data-encoder/src/FormDataLike.ts
Line 43 in 8c8085d
Generator
which makes methods throw
and return
required. But based on the spec, those two are optional for iterators (see here in MDN docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#throwexception) which are linked to in the source of FormDataLike
itself.
I believe the types in undici are more accurate (https://github.com/nodejs/undici/blob/8050ec0224a51d44f776364820e6a16112fb4781/types/formdata.d.ts#L105 and https://github.com/nodejs/undici/blob/8050ec0224a51d44f776364820e6a16112fb4781/types/fetch.d.ts#L41-L47).
This is actually how I found this issue. I was trying to use the FormData object from Undici with the FormDataEncoder from this library.