Skip to content

TypeScript dom lib FormData and File type compatibility #57

Open
@jaydenseric

Description

@jaydenseric

It would be great if the FormData class exported by this package was compatible with the TypeScript dom lib FormData type. The same goes (I guess) for the File class.

This would allow libraries to specify FormData type from the TypeScript dom lib for function arguments, etc. and not cause type problems for projects that are using FormData instances from this package with that.

Screen Shot 2022-07-08 at 9 38 54 am

It looks like the File class needs to have a webkitRelativePath property to be complaint.

MDN links to this spec for the property:

https://wicg.github.io/entries-api/#dom-file-webkitrelativepath

Given that the TypeScript dom lib types don't have webkitRelativePath as an optional type, it must mean it's implemented by all browsers?

For context, I am preparing a big apollo-upload-client update that (among other things) adds type safety and am wondering how to type the function createUploadLink option FormData which allows users to customise the FormData class used; the first thing I'm trying is typeof FormData which references the TypeScript dom lib type, but then in tests it results in a type error when I try to use FormData from this package with that option.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions