formidable-serverless icon indicating copy to clipboard operation
formidable-serverless copied to clipboard

Types definitions

Open rtalexk opened this issue 3 years ago • 5 comments

2022-01-27 12 41 11

In the docs it says it uses the same API as formidable. There's an easy and straightforward to extend the type definitions from formidable to formidable-serverless?

I was thinking in installing like this:

npm i --save formidable-serverless
i --save-dev @types/formidable

And somehow instruct Node to use formidable's types for formidable-serverless.

rtalexk avatar Jan 27 '22 19:01 rtalexk

Yes the types from formidable should work for formidable-serverless as long as the versions match.

I might just create/publish @types/formidable-serverless when I get the chance...

Amit-A avatar Jan 28 '22 00:01 Amit-A

is it done ? @types/ ?

APU-Stark avatar Oct 09 '22 11:10 APU-Stark

a workaround for the error is to use CommonJS import for that const formidable = require("formidable-serverless");

ABDERRAHMANE-OUALI avatar Dec 14 '22 17:12 ABDERRAHMANE-OUALI

Wouldn't that mean formidable is of type any?

EDIT: Could probably cast the above to some variation of typeof import("formidable") to avoid disabling TypeScript unnecessarily.

AverageHelper avatar Dec 14 '22 18:12 AverageHelper

A workaround for this is to copy code from formidable-serverless.js and make a file in your project and paste that code there and then just use import formidable from "./formidable-serverless"; this is the best solution that we have so far. Thanks everyone. I think this issue can be closed for now. (Edit: This solution supports TypeScript)

biladinn avatar Apr 27 '23 21:04 biladinn