-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Typings are incomplete #922
Comments
This is issue on your side:
Property The third argument of the callback function is either |
So - if you are correct - and "This issue is on your side" and the only change I made was an upgrade in version, then it stands to reason, that the "issue" is the upgrade. I am more accustomed to seeing "Breaking changes" listed in the change log. For those that stumble here, (breaking change V1 to V2) there is some detail in the changelog: Additional checking to determine type when you get the call back is needed. per [choutkamartin] above. |
@choutkamartin I ran into the same issue and realized that when I had installed formidable the @types/formidable package that came with it was v1. When I manually added @types/formidable as a dev dependency it came in with v2 and had the correct typings for Files. |
Context
What are you trying to achieve or the steps to reproduce?
Using a formidable form to upload images.
The upgraded version does not appear to match the given typings.
e.g. During run time a form.parse callback contains a File object, which in turn contains an image.
It appears that we need to cast from the specific "Image" back to file, as there is no Image object that implements the File interface.
Compile Error:
TS2339: Property originalFilename does not exist on type File | File[] Property originalFilename does not exist on type File[]
const form = new formidable.IncomingForm(formOpts); form.parse(req, (err: Error, fields: Fields, file: Files) => { file.image.originalFilename }
What was the result you got?
Typescript Compile error
What result did you expect?
Better typings or guidance on expected usage.
The text was updated successfully, but these errors were encountered: