Thanks to visit codestin.com
Credit goes to github.com

Skip to content

(webpack5) Function type notation must be parenthesized when used in a union type.(1385) #10573

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

Closed
3 tasks done
insytes opened this issue Jul 3, 2024 · 0 comments · Fixed by #10575
Closed
3 tasks done
Labels
bug-pending-triage Reported bug, pending triage to confirm.

Comments

@insytes
Copy link
Contributor

insytes commented Jul 3, 2024

Issue Description

⚠️ This is a weird TypeScript bug

When I try to pass an object to mergeWebpack TypeScript complains that the type is not correct.

The type definition for mergeWebpack:

export declare function mergeWebpack(mergeFn: (config: Partial<webpack.Configuration>, env: IWebpackEnv) => any | Partial<webpack.Configuration>): void;

If I try to call mergeWebpack with an object that satisfies Partial<webpack.Configuration> TypeScript complains.

Screenshot 2024-07-03 at 19 01 04

I feel this is a weird TypeScript bug because the type reported in the error message does not match the union type.

It's also weird that to find this bug I had to play with the ordering of the union types to get TypeScript to complain.

Playground

Screenshot 2024-07-03 at 19 11 35

Place the function definition on the left side of the union type and TS will complain that the right side does not exist but it will not complain that Function type notation must be parenthesized when used in a union type.(1385)

Reproduction

No response

Relevant log output (if applicable)

No response

Environment

No response

Please accept these terms

@insytes insytes added the bug-pending-triage Reported bug, pending triage to confirm. label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-pending-triage Reported bug, pending triage to confirm.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant