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

[which-pm] [bug] Return type does not contain null #175

Open
sounisi5011 opened this issue Mar 30, 2023 · 0 comments · May be fixed by #204
Open

[which-pm] [bug] Return type does not contain null #175

sounisi5011 opened this issue Mar 30, 2023 · 0 comments · May be fixed by #204

Comments

@sounisi5011
Copy link

sounisi5011 commented Mar 30, 2023

declare function whichpm (pkgPath: string): Promise<whichpm.Result>

type Result = NPM | YARN | PNPM | Other

In this type declaration, the return type is defined as Promise<whichpm.NPM | whichpm.YARN | whichpm.PNPM | whichpm.Other>.

However, according to the actual code, this function could return null.

return modulesExists ? { name: 'npm' } : null

Therefore, the correct return type is Promise<whichpm.NPM | whichpm.YARN | whichpm.PNPM | whichpm.Other | null>.

This type declaration should add null to the type whichpm.Result.

-   type Result = NPM | YARN | PNPM | Other
+   type Result = NPM | YARN | PNPM | Other | null

Or, should add null to the return type.

- declare function whichpm (pkgPath: string): Promise<whichpm.Result>
+ declare function whichpm (pkgPath: string): Promise<whichpm.Result | null>
@sounisi5011 sounisi5011 changed the title [which-pm] Return type does not contain null [which-pm] [bug] Return type does not contain null Apr 11, 2023
@bluwy bluwy linked a pull request Aug 31, 2024 that will close this issue
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 a pull request may close this issue.

1 participant