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

as in mapped types + intersection + conditional type = ugliness #10667

Open
thorn0 opened this issue Apr 9, 2021 · 1 comment
Open

as in mapped types + intersection + conditional type = ugliness #10667

thorn0 opened this issue Apr 9, 2021 · 1 comment
Labels
area:intersection types lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program

Comments

@thorn0
Copy link
Member

thorn0 commented Apr 9, 2021

That's quite a combo:

Prettier 2.2.1
Playground link

--parser typescript

Input:

export type EntityPrimaryColumnValueMap<
  Entity extends AnyEntity,
  Deepness extends string = "."
> = FlatTypeHint<
  {
    [
      P in keyof (Entity["columns"] & Entity["embeds"])
      as EntityPrimaryColumnValueMapAsCondition<Entity, P> extends true ? P : never
    ]: P extends keyof Entity["columns"]
      ? ColumnCompileType<Entity, P>
      : P extends keyof Entity["embeds"]
      ? EntityPrimaryColumnValueMap<Entity["embeds"][P], `${Deepness}.`>
      : never
  }
>

Output:

export type EntityPrimaryColumnValueMap<
  Entity extends AnyEntity,
  Deepness extends string = "."
> = FlatTypeHint<
  {
    [P in keyof (Entity["columns"] &
      Entity["embeds"]) as EntityPrimaryColumnValueMapAsCondition<
      Entity,
      P
    > extends true
      ? P
      : never]: P extends keyof Entity["columns"]
      ? ColumnCompileType<Entity, P>
      : P extends keyof Entity["embeds"]
      ? EntityPrimaryColumnValueMap<Entity["embeds"][P], `${Deepness}.`>
      : never;
  }
>;

Originally posted by @pleerock in #10642 (comment)

@thorn0 thorn0 added area:intersection types lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program labels Apr 9, 2021
@thorn0 thorn0 mentioned this issue Apr 9, 2021
@texastoland
Copy link

Still an issue 🙋🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:intersection types lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants