Skip to content

Parentheses shouldn't be removed from inferred function return types with extends constraints #13275

@rossipedia

Description

@rossipedia

Prettier 2.7.1
Playground link

--parser babel-ts

Input:

type Foo<T> = T extends (...a: any[]) => (infer R extends string) ? R : never;

Output:

type Foo<T> = T extends (...a: any[]) => infer R extends string ? R : never;

Expected behavior:

The parentheses around (infer R extends string) should be preserved. Removing them results in an error with TypeScript, as shown in the TS Playground (link):

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions