-
Notifications
You must be signed in to change notification settings - Fork 224
fix: avoid incorrect additionalProperties for Pick<..., AliasLiteralUnion> #2230
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
fix: avoid incorrect additionalProperties for Pick<..., AliasLiteralUnion> #2230
Conversation
|
The issue is not fully resolved yet. Turns out the fix does not cover all union key types. Investigating |
There was a problem hiding this 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];
|
If you want, we can merge this PR as is and open another one with the proper fix :) |
|
I don't mind, let's merge this one as a first step |
|
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" |
|
I created the new issue so we can keep track of it. @alexchexes, would you like to work on it, too? |
|
🚀 PR was released in |
|
Yep, already in progress. |
Closes #2229
Version
Published prerelease version:
v2.4.1-next.0Changelog
🎉 This release contains work from a new contributor! 🎉
Thank you, null@alexchexes, for all your work!
🐛 Bug Fix
🔩 Dependency Updates
Authors: 2