Suggestions regarding typescript + export = FormData
See original GitHub issueOne of our users ran into a problem due to the typing of form-data π¦ Specifically the error:
tsc --outDir lib
node_modules/gitlab/dist/infrastructure/index.d.ts:2:8 - error TS1259: Module '"D:/my-project/node_modules/@types/form-data/index"' can only be default-imported using the 'esModuleInterop' flag
2 import FormData from 'form-data';
~~~~~~~~
node_modules/@types/form-data/index.d.ts:15:1
15 export = FormData;
~~~~~~~~~~~~~~~~~~
This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
In the node-gitlab library, the lines that reference form-data are:
import FormData from 'form-data';
...
export interface DefaultRequestOptions extends Sudo {
body?: object | FormData;
query?: object;
}
And I have esModuleInterlop set in my tsconfig.
Iβm not really sure how to go about solving this problem, any suggestions ? π
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15
Top Results From Across the Web
Suggestions regarding typescript + export = FormData
A module to create readable `"multipart/form-data"` streams. Can be used to submit forms and file uploads to other web applications. See MoreΒ ...
Read more >Require fields in FormData using TypeScript - Stack Overflow
So I want to use TypeScript to check if my formData has all required fields. so I can do: export const mapRequest =...
Read more >Uploading Files with FormData and Post Requests Using ...
In this quick tutorial, we'll learn to upload files in Angular 14 using FormData and POST requests via Angular 14 HttpClient Go to...
Read more >TS Support | React Hook Form - Simple React forms validation
Typescript Support. List of exported Typescript Types. ... Important: Typescript ^4.3 above is the recommended version to work with react hook form.
Read more >typescript-cheatsheet - GitHub Pages
Conversely, to consume a variable, function, class, interface, etc. exported from a different module, it has to be imported using one of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/jdalrymple/node-gitlab/issues/417#issuecomment-526574251 Our solution was changing the import for this one ts file:
https://github.com/jdalrymple/node-gitlab/commit/91cfbf27379be535ed90872ce0ea37b29e206d5c
The problem with making that change everwhere is the creation of another error which correctly states that FormData isnt callable since
import * as FormData from 'form-data'
should be an objectCannot repro. We are consuming
form-data
viarequest
:But making a small repro project, installing
request
and using TypeScript3.5.3
does not recreate the problem. Sorry I canβt help more.