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

fix: inference of optional properties #28

Merged
merged 9 commits into from
Mar 19, 2024

Conversation

KATT
Copy link
Contributor

@KATT KATT commented Mar 19, 2024

Closes #27

Also ran prettier which made the diff a bit bigger

@KATT KATT marked this pull request as ready for review March 19, 2024 17:14
Comment on lines +77 to +88
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
type GetOptionalArgs<TArgs extends Arguments> = {
[TArg in keyof TArgs]: TArgs[TArg]['required'] extends true ? never : TArg
}[keyof TArgs]

/** Represents a map of argument names to argument types. */
export type TransformedArguments<TArgs extends Arguments> = {
[TArg in keyof TArgs]: TransformedArgument<TArgs[TArg]>
}
export type TransformedArguments<TArgs extends Arguments> = PartialBy<
{
[TArg in keyof TArgs]: TransformedArgument<TArgs[TArg]>
},
GetOptionalArgs<TArgs>
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clever 👍

@huytool157 huytool157 merged commit 7b34ce7 into tryretool:main Mar 19, 2024
2 checks passed
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.

Bug(TypeScript): optional properties inferred as omnipresent
2 participants