You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
Specifically #689
refactor: split file.name into file.newFilename and file.originalFilename (#689)
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: