Skip to content

Bad parse for union type and function type #31106

@Kingwl

Description

@Kingwl

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms:
parser, arrow, union

Code

declare const a: string | (a: string, b: boolean) => string
declare const b: string | () => string
declare const c: string | () => string | number | () => boolean

Expected behavior:

declare const a: string | (a: string, b: boolean) => string
>a : string | ((a: string, b: boolean) => string)
>a : string
>b : boolean

declare const b: string | () => string
>b : string | (() => string)

// ?
declare const c: string | () => string | number | () => boolean
>c : string | (() => string | number | (() => boolean))


Actual behavior:
parse error

Playground Link:

Related Issues:
#25898

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions