Skip to content

Conversation

ahejlsberg
Copy link
Member

This PR adds the following predefined mapped types to lib.d.ts:

// Make all properties in T optional
type Partial<T> = {
    [P in keyof T]?: T[P];
};

// Make all properties in T readonly
type Readonly<T> = {
    readonly [P in keyof T]: T[P];
};

// From T pick a set of properties K
type Pick<T, K extends keyof T> = {
    [P in K]: T[P];
}

// Construct a type with a set of properties K of type T
type Record<K extends string | number, T> = {
    [P in K]: T;
}

The PR also property implements the identity relation for mapped types.

@ahejlsberg
Copy link
Member Author

@mhegazy Comments?

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

Successfully merging this pull request may close these issues.

3 participants