-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Fix2 get constraint of indexed access #17912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Nathan Shively-Sanders (sandersn)
merged 12 commits into
master
from
fix2-getConstraintOfIndexedAccess
Jan 10, 2018
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dc85623
Fix #17069 and #15371
sandersn ecae295
Test getConstraintOfIndexedAccess fixes and update baselines
sandersn 85b0969
Merge branch 'master' into fix2-getConstraintOfIndexedAccess
sandersn 04339d2
Disallow T[K] = T[keyof T] where K extends keyof T
sandersn 20e5798
Test:T[keyof T] =/=> T[K] where K extends keyof T
sandersn 28a6ac3
Merge branch 'master' into fix2-getConstraintOfIndexedAccess
sandersn 2f646da
Move lone test case into central test file
sandersn dd0fa41
Merge branch 'master' into fix2-getConstraintOfIndexedAccess
sandersn 71b7429
Update baselines
sandersn 7dbea0e
Merge branch 'master' into fix2-getConstraintOfIndexedAccess
sandersn 0b23811
Handle indexed mapped types in transformIndexedAccessType
sandersn 8f45373
Rename simplifyIndexedAccessType->getSimplifiedIndexedAccessType
sandersn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //// [additionOperatorWithConstrainedTypeParameter.ts] | ||
| // test for #17069 | ||
| function sum<T extends Record<K, number>, K extends string>(n: number, v: T, k: K) { | ||
| n = n + v[k]; | ||
| n += v[k]; // += should work the same way | ||
| } | ||
| function realSum<T extends Record<K, number>, K extends string>(n: number, vs: T[], k: K) { | ||
| for (const v of vs) { | ||
| n = n + v[k]; | ||
| n += v[k]; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| //// [additionOperatorWithConstrainedTypeParameter.js] | ||
| // test for #17069 | ||
| function sum(n, v, k) { | ||
| n = n + v[k]; | ||
| n += v[k]; // += should work the same way | ||
| } | ||
| function realSum(n, vs, k) { | ||
| for (var _i = 0, vs_1 = vs; _i < vs_1.length; _i++) { | ||
| var v = vs_1[_i]; | ||
| n = n + v[k]; | ||
| n += v[k]; | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| === tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts === | ||
| // test for #17069 | ||
| function sum<T extends Record<K, number>, K extends string>(n: number, v: T, k: K) { | ||
| >sum : Symbol(sum, Decl(additionOperatorWithConstrainedTypeParameter.ts, 0, 0)) | ||
| >T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 13)) | ||
| >Record : Symbol(Record, Decl(lib.d.ts, --, --)) | ||
| >K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) | ||
| >K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) | ||
| >v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) | ||
| >T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 13)) | ||
| >k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) | ||
| >K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 41)) | ||
|
|
||
| n = n + v[k]; | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) | ||
| >v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) | ||
| >k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) | ||
|
|
||
| n += v[k]; // += should work the same way | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 60)) | ||
| >v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 70)) | ||
| >k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 1, 76)) | ||
| } | ||
| function realSum<T extends Record<K, number>, K extends string>(n: number, vs: T[], k: K) { | ||
| >realSum : Symbol(realSum, Decl(additionOperatorWithConstrainedTypeParameter.ts, 4, 1)) | ||
| >T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 17)) | ||
| >Record : Symbol(Record, Decl(lib.d.ts, --, --)) | ||
| >K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) | ||
| >K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) | ||
| >vs : Symbol(vs, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 74)) | ||
| >T : Symbol(T, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 17)) | ||
| >k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) | ||
| >K : Symbol(K, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 45)) | ||
|
|
||
| for (const v of vs) { | ||
| >v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) | ||
| >vs : Symbol(vs, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 74)) | ||
|
|
||
| n = n + v[k]; | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) | ||
| >v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) | ||
| >k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) | ||
|
|
||
| n += v[k]; | ||
| >n : Symbol(n, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 64)) | ||
| >v : Symbol(v, Decl(additionOperatorWithConstrainedTypeParameter.ts, 6, 14)) | ||
| >k : Symbol(k, Decl(additionOperatorWithConstrainedTypeParameter.ts, 5, 83)) | ||
| } | ||
| } | ||
|
|
64 changes: 64 additions & 0 deletions
64
tests/baselines/reference/additionOperatorWithConstrainedTypeParameter.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| === tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithConstrainedTypeParameter.ts === | ||
| // test for #17069 | ||
| function sum<T extends Record<K, number>, K extends string>(n: number, v: T, k: K) { | ||
| >sum : <T extends Record<K, number>, K extends string>(n: number, v: T, k: K) => void | ||
| >T : T | ||
| >Record : Record<K, T> | ||
| >K : K | ||
| >K : K | ||
| >n : number | ||
| >v : T | ||
| >T : T | ||
| >k : K | ||
| >K : K | ||
|
|
||
| n = n + v[k]; | ||
| >n = n + v[k] : number | ||
| >n : number | ||
| >n + v[k] : number | ||
| >n : number | ||
| >v[k] : T[K] | ||
| >v : T | ||
| >k : K | ||
|
|
||
| n += v[k]; // += should work the same way | ||
| >n += v[k] : number | ||
| >n : number | ||
| >v[k] : T[K] | ||
| >v : T | ||
| >k : K | ||
| } | ||
| function realSum<T extends Record<K, number>, K extends string>(n: number, vs: T[], k: K) { | ||
| >realSum : <T extends Record<K, number>, K extends string>(n: number, vs: T[], k: K) => void | ||
| >T : T | ||
| >Record : Record<K, T> | ||
| >K : K | ||
| >K : K | ||
| >n : number | ||
| >vs : T[] | ||
| >T : T | ||
| >k : K | ||
| >K : K | ||
|
|
||
| for (const v of vs) { | ||
| >v : T | ||
| >vs : T[] | ||
|
|
||
| n = n + v[k]; | ||
| >n = n + v[k] : number | ||
| >n : number | ||
| >n + v[k] : number | ||
| >n : number | ||
| >v[k] : T[K] | ||
| >v : T | ||
| >k : K | ||
|
|
||
| n += v[k]; | ||
| >n += v[k] : number | ||
| >n : number | ||
| >v[k] : T[K] | ||
| >v : T | ||
| >k : K | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSimplifiedIndexAccessType