Skip to content

Conversation

@alexchexes
Copy link
Contributor

@alexchexes alexchexes commented Apr 13, 2025

Closes #2229

Version

Published prerelease version: v2.4.1-next.0

Changelog

🎉 This release contains work from a new contributor! 🎉

Thank you, null@alexchexes, for all your work!

🐛 Bug Fix

  • fix: avoid incorrect additionalProperties for Pick<..., AliasLiteralUnion> #2230 (@alexchexes)

🔩 Dependency Updates

Authors: 2

@alexchexes alexchexes marked this pull request as draft April 13, 2025 15:09
@alexchexes
Copy link
Contributor Author

The issue is not fully resolved yet. Turns out the fix does not cover all union key types. Investigating

@arthurfiorette arthurfiorette self-assigned this Apr 13, 2025
@arthurfiorette arthurfiorette requested a review from Copilot April 13, 2025 22:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • test/valid-data/type-mapped-pick-union-alias/schema.json: Language not supported
Comments suppressed due to low confidence (1)

src/NodeParser/MappedTypeNodeParser.ts:161

  • [nitpick] Consider adding an inline comment to clarify why dereferencing with derefType is necessary here, to help future maintainers understand this filtering logic.
const key = keyListType.getTypes().filter((type) => !(derefType(type) instanceof LiteralType))[0];

@arthurfiorette
Copy link
Collaborator

If you want, we can merge this PR as is and open another one with the proper fix :)

@alexchexes
Copy link
Contributor Author

I don't mind, let's merge this one as a first step

@alexchexes alexchexes marked this pull request as ready for review April 13, 2025 23:20
@alexchexes
Copy link
Contributor Author

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"

@arthurfiorette arthurfiorette merged commit 7560952 into vega:next Apr 14, 2025
3 of 4 checks passed
@arthurfiorette
Copy link
Collaborator

I created the new issue so we can keep track of it. @alexchexes, would you like to work on it, too?

@github-actions
Copy link

🚀 PR was released in v2.4.1-next.0 🚀

@alexchexes
Copy link
Contributor Author

Yep, already in progress.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect additionalProperties schema generated for Pick<T, AliasLiteralUnion>

2 participants