Skip to content

Pick with union of unions of literals generates wrong additionalProperties. #2231

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

Open
arthurfiorette opened this issue Apr 14, 2025 · 1 comment · May be fixed by #2232
Open

Pick with union of unions of literals generates wrong additionalProperties. #2231

arthurfiorette opened this issue Apr 14, 2025 · 1 comment · May be fixed by #2232
Assignees

Comments

@arthurfiorette
Copy link
Collaborator

          Just to clarify what's not covered in this PR: the fix only dereferences the top-level union keys, but not nested aliases.

For example:

SomeInterface {
  a: number;
  b: string;
  c: boolean;
}

type AB = "a" | "b";
type C = "c";

export type Test = Pick<SomeInterface, AB | C>;

still produces unexpected "additionalProperties"

Originally posted by @alexchexes in #2230 (comment)

@alexchexes
Copy link
Contributor

Working on it.

To solve this, in MappedTypeNodeParser.getAdditionalProperties() we need to deeply check if the given type is a union composed entirely of literal types by recursively dereferencing each nested type. Going to create isDeepLiteralUnion() helper in the Utils/derefType.

alexchexes added a commit to alexchexes/ts-json-schema-generator that referenced this issue Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants