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

[@types/yargs] Yargs type for default might be wrong #68089

Open
davidmurdoch opened this issue Jan 3, 2024 · 1 comment
Open

[@types/yargs] Yargs type for default might be wrong #68089

davidmurdoch opened this issue Jan 3, 2024 · 1 comment

Comments

@davidmurdoch
Copy link

Currently the inferred types comes from:

            // Use the type of `default` as the last resort
            : O extends ({ default: infer D }) ? Exclude<D, undefined>

see: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/ba6c5b11a9d9ff910766625d58a45743a70f6503/types/yargs/index.d.ts#L931C17-L931C17

But I think this should be something like:

        // Use the type of `default` as the last resort
        : O extends (
            { default: infer D }
        ) ? D extends (
            (...args: any) => any
        // since default is a function, use its return type
        ) ? Exclude<ReturnType<D>, undefined>
        : Exclude<D, undefined>

but I'm not 100%. Hopefully someone with know-how knows more.

@Akiyamka
Copy link

Akiyamka commented Apr 1, 2024

It seems related yargs/yargs#2292

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

No branches or pull requests

2 participants