Skip to content
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

TS Options Type Definition missing createDirsFromUploads #951

Closed
lou-alfaro opened this issue Jul 31, 2023 · 1 comment
Closed

TS Options Type Definition missing createDirsFromUploads #951

lou-alfaro opened this issue Jul 31, 2023 · 1 comment
Labels

Comments

@lou-alfaro
Copy link

lou-alfaro commented Jul 31, 2023

Support plan

  • Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
  • Currently blocking your project/work? (yes/no): no
  • Affecting a production system? (yes/no): no

Context

  • Node.js version: 18.15.0
  • Release Line of Formidable (Legacy, Current, Next): Current
  • Formidable exact version: 3.5.0
  • Environment (node, browser, native, OS): node
  • Used with (popular names of modules): NextJS, TS

What are you trying to achieve or the steps to reproduce?

const form = formidable({
    filename: (_name, _ext, part) => `${Date.now()}/${part.originalFilename}`,
    createDirsFromUploads: true,
});

What was the result you got?

Argument of type '{ filename: (_name: string, _ext: string, part: Part) => string; createDirsFromUploads: boolean; }' is not assignable to parameter of type 'Options'.
  Object literal may only specify known properties, and 'createDirsFromUploads' does not exist in type 'Options'.ts(2345)

What result did you expect?

createDirsFromUploads should exist on type Options in order to be able to override option in a type safe way.

Current Workaround

Type coercion to unknown as follows

const form = formidable({
    filename: (_name, _ext, part) => `${Date.now()}/${part.originalFilename}`,
    createDirsFromUploads: true,
} as unknown);

this silences the ts error without also causing the no-explicit-type-any eslint errors

@lou-alfaro lou-alfaro added the bug label Jul 31, 2023
@hyperupcall
Copy link

It looks like this has been fixed by DefinitelyTyped/DefinitelyTyped#66332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants