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

clientgen/typescript: Add parentheses when lists element type is union #1304

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

fredr
Copy link
Member

@fredr fredr commented Aug 2, 2024

Fixes wrapping list of unions with parentheses

interface Response {
  message: string;
  item?: Item;
}

interface X {
  a: string;
}
interface Y {
  b: (keyof X)[];
}

type Thing = { a: string; b: number };
type Item = {
  keys: (keyof Thing)[];
  otherField: ((X & Y) | X | Y)[];
};

Now generates the following type:

export interface Item {
    keys: ("a" | "b")[]
    otherField: ({
        a: string
        b: "a"[]
    } | X | Y)[]
}

@fredr fredr requested a review from eandre August 2, 2024 11:18
@fredr fredr self-assigned this Aug 2, 2024
@encore-cla
Copy link

encore-cla bot commented Aug 2, 2024

All committers have signed the CLA.

@fredr fredr force-pushed the fredr/fix-list-of-union branch from f7bcbcd to 88974b5 Compare August 2, 2024 11:52
@fredr fredr merged commit 8b08733 into main Aug 2, 2024
4 checks passed
@fredr fredr deleted the fredr/fix-list-of-union branch August 2, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants