GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Predefined mapped types in lib.d.ts by ahejlsberg · Pull Request #12276 · microsoft/TypeScript

Conversation

@ahejlsberg

@ahejlsberg Anders Hejlsberg (ahejlsberg) commented Nov 15, 2016

Copy link
Copy Markdown
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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tinganho, normalser, geir-bakke, iKBAHT, GoToLoop, mDibyo, rictic, aluanhaddad, mpawelski, haxiomic, and 2 more reacted with thumbs up emoji haxiomic reacted with hooray emoji
All reactions
  • 👍 12 reactions
  • 🎉 1 reaction
Anders Hejlsberg (ahejlsberg) added 4 commits November 15, 2016 12:14
@ahejlsberg
Properly handle identity relation for mapped types
fe3f88c
@ahejlsberg
Add predefined mapped types and revise Object.freeze
d32196f
@ahejlsberg
Revise tests
04a0f55
@ahejlsberg
Accept new baselines
997c586
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Nov 15, 2016
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Nov 15, 2016

Copy link
Copy Markdown
Member Author

Mohamed Hegazy (@mhegazy) Comments?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mhegazy
Mohamed Hegazy (mhegazy) approved these changes Nov 15, 2016
View reviewed changes
@ahejlsberg
Anders Hejlsberg (ahejlsberg) merged commit 0ba2348 into master Nov 15, 2016
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the libMappedTypes branch November 15, 2016 21:19
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request Nov 15, 2016
Mapped types #12114
Merged
@weswigham Wesley Wigham (weswigham) mentioned this pull request Nov 16, 2016
Snapshot nightlies during the night #12283
Closed
@dead-claudia Claudia Meadows (dead-claudia) mentioned this pull request Nov 17, 2016
Partial Types (Optionalized Properties for Existing Types) #4889
Closed
@gcnew Marin Marinov (gcnew) mentioned this pull request Nov 21, 2016
Flow Analyze don't recognize combined Intersection and Union Type #12345
Closed
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@mhegazy Mohamed Hegazy (mhegazy) mhegazy approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ahejlsberg @mhegazy @msftclas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.