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

Closed
@insytes

Description

@insytes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-pending-triageReported bug, pending triage to confirm.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions