Problem Statement
Remove optional modifiers via mapped type:
Explanation
In mapped types, “-?” removes optional, “+?” adds optional. Similarly, “-readonly” removes readonly and “+readonly” adds it.
Code Solution
SolutionRead Only
type Requiredify<T> = { [K in keyof T]-?: T[K] };
// { a?: number } -> { a: number }