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

Incorrect typing when using a default function #2401

Open
Nabrok opened this issue Apr 19, 2024 · 1 comment
Open

Incorrect typing when using a default function #2401

Nabrok opened this issue Apr 19, 2024 · 1 comment

Comments

@Nabrok
Copy link

Nabrok commented Apr 19, 2024

Given

.option('text', {
  type: 'string',
  default: function getTheDefault(): string {
    return 'default';
  }
)

Typescript gives the typing of the result string | (() => string).

However, after parsing without a value what I get for the option is the return value of the function, not the function itself.

As typescript now thinks text could be a function it won't work in places that expect a string.

@shadowspawn
Copy link
Member

The TypeScript types are maintained separately on DefinitelyTyped, so you might want to open an issue/discussion there too.

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

No branches or pull requests

2 participants