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 — Higher order type relations for mapped types by ahejlsberg · Pull Request #12351 · microsoft/TypeScript

Conversation

@ahejlsberg

@ahejlsberg Anders Hejlsberg (ahejlsberg) commented Nov 18, 2016 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This PR adds a number of type relations for higher order mapped types and indexed access types (i.e. un-instantiated generic forms of the types).

  • A type S[K] is related to a type T[K] if S is related to T.
  • A type T is related to a type { [P in keyof T]: X } if T[P] is related to X.
  • A type { [P in keyof T]: X } is related to a type T if X is related to T[P].

The PR furthermore adds the following rules:

  • The operation keyof { [P in K]: X } is equivalent to just K. For example, keyof Partial<T> is equivalent to keyof T.
  • The operation { [P in K]: T}[X] is equivalent to an instantiation of T where X is substituted for every occurrence of P. For example, { [P in K]: Box<T[P]> }[X] is equivalent to Box<T[X]>.
  • In type T = { [P in K]: X } it is an error for K to directly or indirectly reference T.
  • Given a type parameter T with a constraint that includes a string index signature of type X, the apparent type of an indexed access type T[K] is X.

Fixes #12311.
Fixes #12315.

Sorry, something went wrong.

Uh oh!

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

alitaheri reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Anders Hejlsberg (ahejlsberg) added 4 commits November 17, 2016 20:18
@ahejlsberg
Type relations for generic mapped types
2646828
@ahejlsberg
Error on circular constraints in mapped types
63387bb
@ahejlsberg
Accept new baselines
79bdc26
@ahejlsberg
Add new tests
075a3eb
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Nov 18, 2016
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request Nov 18, 2016
Indexing constraints on mapped type should use the constraint type #12315
Closed
Anders Hejlsberg (ahejlsberg) added 2 commits November 18, 2016 13:30
@ahejlsberg
Support apparent types for T[K] indexed access types
2376e30
@ahejlsberg
Add tests
a789990
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request Nov 18, 2016
Cannot access indexed type of constrained type parameter #12340
Closed
mhegazy
Mohamed Hegazy (mhegazy) approved these changes Nov 18, 2016
View reviewed changes
@ahejlsberg
Anders Hejlsberg (ahejlsberg) merged commit e81da9c into master Nov 18, 2016
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the mappedTypeRelations branch November 18, 2016 22:10
Mohamed Hegazy (mhegazy) pushed a commit that referenced this pull request Nov 18, 2016
@ahejlsberg @mhegazy
Merge pull request #12351 from Microsoft/mappedTypeRelations
6dea1a0
Higher order type relations for mapped types
@mhegazy Mohamed Hegazy (mhegazy) mentioned this pull request Nov 18, 2016
Port #12351 to release-2.1 #12368
Merged
Mohamed Hegazy (mhegazy) added a commit that referenced this pull request Nov 18, 2016
@mhegazy
Merge pull request #12368 from Microsoft/Port12351-3
b8f6227
Port #12351  to release-2.1
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request Nov 19, 2016
Mapped types #12114
Merged
@vknez vknez mentioned this pull request Dec 9, 2016
Mapped types with strictNullChecks and React setState() - Could this be a reliable solution? #12801
Closed
@ahejlsberg Anders Hejlsberg (ahejlsberg) mentioned this pull request May 30, 2017
Indexed access behavior differs between type aliases and type parameters. #16036
Closed
@jaen jaen (jaen) mentioned this pull request Jul 16, 2017
Lookup across a mapped type gives different result when using a generic alias #15756
Closed
This was referenced Jul 17, 2017
Bug with mapped types and indexing #17238
Closed
Mapped types fixes #17336
Closed
@gcnew Marin Marinov (gcnew) mentioned this pull request Jul 27, 2017
suggestion: dynamic function type gcanti/typelevel-ts#8
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.