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

Partialise a Record type? #52

Open
yuhr opened this issue May 9, 2018 · 2 comments
Open

Partialise a Record type? #52

yuhr opened this issue May 9, 2018 · 2 comments

Comments

@yuhr
Copy link
Collaborator

yuhr commented May 9, 2018

const Info = Record({
  x: Number
}).And(Partial({
  y: Number
}));
const AllPartialInfo = Partialize(Info);
type AllPartialInfo = Static<typeof AllPartialInfo>;
// -> { x?: number | undefined; } & { y?: number | undefined; }

Is there something like above Partialize?

@jraoult
Copy link

jraoult commented Jan 5, 2019

For the record @yuhr (I realised this issue is quite old) just had to do that today, I think what you want is: Partial(Info.fields)

@KingDarBoja
Copy link

I know this issue is old but would be great to document this little option at the readme, something like:

You can extract the fields of a runtype to perform extra operations without modifying the original runtype record.

And put that "Partialize" as example.

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

No branches or pull requests

3 participants