I am importing a type which for some reason is entirely consisted of optional types. So something like this (but instead with over a dozen attributes):
type MyType {
id?: string
name?: string
age?: number
description?: string
}
This is causing some issues as I do need for some of these to be required. I know there is the Required utility type which turns all attributes into required.
The issue is, then I have the opposite problem in which indeed some of the types are intended to be optional.
What I would like to do is to change MyType
in such a way that I can pick which attributes should be mandatory and which should be optional. Ideally I would like it to look something like this:
type MyType {
id: string // required
name: string // required
age?: number // optional
description?: string // optional
}
Is there a util type or something else I can do to cherry-pick which ones I'd like to make mandatory and which ones should remain optional?
Thanks!