You might also be able to find a solution fromAI solution orcommunity posts
BFE.dev solution for TypeScript puzzle
1. implement Partial<T>
From the description, we see that the goal is to make every property optional for an object.
type Foo = { a: string b: number c: boolean}
MyPartial<Foo>
should be
type PartialFoo = { a?: string b?: number c?: boolean}
We need to map each property to its optional form. Mapped Types comes in handy.
type MyPartial<T> = { [P in keyof T]?: T[P]}
keyof T
holds all the property keys of T, [P in keyof T]
is to
iterate over all of them. And it maps each key to T[P]
which is the value type.
Notice the use of ?
to make keys as optional.