Grokking TypeScript
Vote

0% completed

​

Utility Types

Partial<T> is not a special feature of the compiler. It is a mapped type of three lines, written in ordinary TypeScript in a standard library file named lib.es5.d.ts, and the same file holds the other types in this lesson. Apart from the name, the library's definition is exactly this.

type MyPartial<T> = { [P in keyof T]?: T[P]; };

The examples here use names such as MyPartial because the built-in names are already declared globally. Declaring Partial again in a script file reports error TS2300: Duplicate identifier 'Partial'.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content