Skip to content

fix(types): add optional value to MultipartFile for onFile#624

Open
imharjot wants to merge 1 commit into
fastify:mainfrom
imharjot:fix/multipartfile-value-type
Open

fix(types): add optional value to MultipartFile for onFile#624
imharjot wants to merge 1 commit into
fastify:mainfrom
imharjot:fix/multipartfile-value-type

Conversation

@imharjot

@imharjot imharjot commented Jun 17, 2026

Copy link
Copy Markdown

The README documents setting part.value inside an onFile handler when using
attachFieldsToBody: 'keyValues', but MultipartFile has no value property, so that
example fails to typecheck with TS2339 (Property 'value' does not exist on type 'MultipartFile').

Adds an optional value?: unknown to MultipartFile. unknown (not any) keeps it
type-safe and matches the existing Record<string, unknown> usage in this file; it's
optional because a file part only gets a value when one is assigned in onFile. Kept
MultipartFile non-generic to avoid rippling generics through Multipart/MultipartFields.

The existing type test asserted req.body.file had no value, so that assertion is flipped
and the onFile test handler now assigns part.value to cover the regression.

Fixes #574

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type value does not exist on MultipartFile when using onFile

1 participant