Skip to content
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

Index signatures for symbols and template literal strings #44512

Merged
merged 59 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
95dc813
Switch index signature storage to 'indexInfos: IndexInfo[]' property
ahejlsberg May 31, 2021
fc107dc
Accept new baselines
ahejlsberg May 31, 2021
60cff44
Remove another usage of IndexKind enum
ahejlsberg May 31, 2021
9900302
Update getIndexedAccessType and resolveMappedTypeMembers
ahejlsberg Jun 1, 2021
f27bea2
Accept new baselines
ahejlsberg Jun 1, 2021
a064ec1
Update grammar checking for index signatures
ahejlsberg Jun 2, 2021
01cb825
Accept new baselines
ahejlsberg Jun 2, 2021
8622ae6
Consider all index signatures in mapped types and union types
ahejlsberg Jun 2, 2021
7285cb9
Accept new baselines
ahejlsberg Jun 2, 2021
4bd05bc
Update getIndexType
ahejlsberg Jun 2, 2021
a91782f
Accept new baselines
ahejlsberg Jun 2, 2021
730ded4
Intersect multiple applicable index signatures
ahejlsberg Jun 3, 2021
c6cc9a1
Use getApplicableIndexInfo instead of hardwired string/number handling
ahejlsberg Jun 3, 2021
bed9264
Update index signature relationship checking
ahejlsberg Jun 4, 2021
cf0b614
Report type for which index signature is missing
ahejlsberg Jun 4, 2021
2c0bf2b
Report type for which index signature is missing
ahejlsberg Jun 4, 2021
041a12f
Accept new baselines
ahejlsberg Jun 4, 2021
61297e3
Make 'number' index signatures consistently apply to numeric strings
ahejlsberg Jun 5, 2021
7f0f4c3
Accept new baselines
ahejlsberg Jun 5, 2021
9442790
Update fourslash test
ahejlsberg Jun 5, 2021
f96f513
Revise index constraint checking
ahejlsberg Jun 6, 2021
91e3546
Accept new baselines
ahejlsberg Jun 6, 2021
f24a654
Update error messages
ahejlsberg Jun 6, 2021
f2a20cc
Accept new baselines
ahejlsberg Jun 6, 2021
135e181
Update type inference from index signatures
ahejlsberg Jun 6, 2021
0c27c9c
Update isKnownProperty
ahejlsberg Jun 6, 2021
b8ac093
Update contextual typing based on index signatures
ahejlsberg Jun 7, 2021
b2a014c
Accept new baselines
ahejlsberg Jun 7, 2021
ab96d54
Support union types in index signature declarations
ahejlsberg Jun 7, 2021
bed7008
Accept new baselines
ahejlsberg Jun 7, 2021
a880248
Check duplicate index signatures / remove redundant template literals…
ahejlsberg Jun 7, 2021
dccec9a
Accept new baselines
ahejlsberg Jun 7, 2021
535c5e3
Include key type in diagnostic / check symbol-named properties
ahejlsberg Jun 8, 2021
cf8b547
Accept new baselines
ahejlsberg Jun 8, 2021
077c960
Minor fix
ahejlsberg Jun 8, 2021
96390ca
Add tests
ahejlsberg Jun 8, 2021
b7c9038
Accept new baselines
ahejlsberg Jun 8, 2021
2039e04
Merge branch 'main' into moreIndexSignatures
ahejlsberg Jun 8, 2021
a92a41b
Add optimized findApplicableIndexInfoForName
ahejlsberg Jun 9, 2021
8dd8e38
Accept new baselines
ahejlsberg Jun 9, 2021
9e3f8ce
Another place we don't need to obtain literal type for property name
ahejlsberg Jun 9, 2021
a98ff6d
Accept new baselines
ahejlsberg Jun 9, 2021
8b2098d
Don't create literal types that are going to be discarded
ahejlsberg Jun 10, 2021
d357fa0
Individual maps for string, number, bigint, and enum literal types
ahejlsberg Jun 10, 2021
cfd67e6
Remove ineffective optimizations
ahejlsberg Jun 11, 2021
e807041
Accept new baselines
ahejlsberg Jun 11, 2021
5354b39
Permit intersections as key types in index signatures
ahejlsberg Jun 15, 2021
4d0a3e0
Index expression in element access is template literal context
ahejlsberg Jun 15, 2021
00c7549
Add tests
ahejlsberg Jun 15, 2021
7a5ec8d
Accept new baselines
ahejlsberg Jun 15, 2021
c27ba9b
Merge branch 'main' into moreIndexSignatures
ahejlsberg Jun 15, 2021
bf633d8
Symbol index signatures from object literals with computed symbol pro…
ahejlsberg Jun 18, 2021
5baae83
Accept new baselines
ahejlsberg Jun 18, 2021
2f4c967
Add more tests
ahejlsberg Jun 18, 2021
f3897c1
Accept new baselines
ahejlsberg Jun 18, 2021
ef47fa1
Merge branch 'main' into moreIndexSignatures
ahejlsberg Jun 18, 2021
fbffa7c
Implement Go To Definition for all applicable index signatures
ahejlsberg Jun 19, 2021
128e125
Add fourslash test
ahejlsberg Jun 19, 2021
1e376a5
Accept new API baselines
ahejlsberg Jun 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Jun 5, 2021
commit 7f0f4c3b37cbc7f98bc048416e38d84bcb28962b
6 changes: 3 additions & 3 deletions tests/baselines/reference/bigintIndex.types
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ let num: number = arr[1];
>1 : 1

num = arr["1"];
>num = arr["1"] : any
>num = arr["1"] : number
>num : number
>arr["1"] : any
>arr["1"] : number
>arr : number[]
>"1" : "1"

Expand Down Expand Up @@ -84,7 +84,7 @@ typedArray[String(bigNum)] = 0xAA;

typedArray["1"] = 0xBB;
>typedArray["1"] = 0xBB : 187
>typedArray["1"] : any
>typedArray["1"] : number
>typedArray : Uint8Array
>"1" : "1"
>0xBB : 187
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function other<T extends Date>(arg: T) {
>1 : 1

var e = r2['1'];
>e : Object
>r2['1'] : Object
>e : T
>r2['1'] : T
>r2 : { [x: string]: Object; [x: number]: T; }
>'1' : "1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function other3<T extends U, U extends Date>(arg: T) {
>1 : 1

var e = r2['1'];
>e : Object
>r2['1'] : Object
>e : T
>r2['1'] : T
>r2 : { [x: string]: Object; [x: number]: T; }
>'1' : "1"

Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/mergedInterfacesWithIndexers.types
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var r = a[1];
>1 : 1

var r2 = a['1'];
>r2 : { length: number; }
>a['1'] : { length: number; }
>r2 : string
>a['1'] : string
>a : A
>'1' : "1"

Expand Down
28 changes: 14 additions & 14 deletions tests/baselines/reference/numericIndexingResults.types
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var r2 = c['2'];
>'2' : "2"

var r3 = c['3'];
>r3 : error
>c['3'] : error
>r3 : string
>c['3'] : string
>c : C
>'3' : "3"

Expand Down Expand Up @@ -80,8 +80,8 @@ var r2 = i['2'];
>'2' : "2"

var r3 = i['3'];
>r3 : error
>i['3'] : error
>r3 : string
>i['3'] : string
>i : I
>'3' : "3"

Expand Down Expand Up @@ -129,8 +129,8 @@ var r2 = a['2'];
>'2' : "2"

var r3 = a['3'];
>r3 : error
>a['3'] : error
>r3 : string
>a['3'] : string
>a : { [x: number]: string; 1: string; "2": string; }
>'3' : "3"

Expand Down Expand Up @@ -162,20 +162,20 @@ var b: { [x: number]: string } = { 1: '', "2": '' }
>'' : ""

var r1a = b['1'];
>r1a : error
>b['1'] : error
>r1a : string
>b['1'] : string
>b : { [x: number]: string; }
>'1' : "1"

var r2a = b['2'];
>r2a : error
>b['2'] : error
>r2a : string
>b['2'] : string
>b : { [x: number]: string; }
>'2' : "2"

var r3 = b['3'];
>r3 : error
>b['3'] : error
>r3 : string
>b['3'] : string
>b : { [x: number]: string; }
>'3' : "3"

Expand Down Expand Up @@ -221,8 +221,8 @@ var r2b = b2['2'];
>'2' : "2"

var r3 = b2['3'];
>r3 : error
>b2['3'] : error
>r3 : string
>b2['3'] : string
>b2 : { [x: number]: string; 1: string; "2": string; }
>'3' : "3"

Expand Down
8 changes: 1 addition & 7 deletions tests/baselines/reference/objectRest.errors.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
tests/cases/conformance/types/rest/objectRest.ts(7,12): error TS2339: Property '0' does not exist on type 'String'.
tests/cases/conformance/types/rest/objectRest.ts(7,20): error TS2339: Property '1' does not exist on type 'String'.
tests/cases/conformance/types/rest/objectRest.ts(43,8): error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
tests/cases/conformance/types/rest/objectRest.ts(43,35): error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
tests/cases/conformance/types/rest/objectRest.ts(43,57): error TS2403: Subsequent variable declarations must have the same type. Variable 'o' must be of type '{ a: number; b: string; }', but here has type '{}'.
Expand All @@ -8,18 +6,14 @@ tests/cases/conformance/types/rest/objectRest.ts(44,32): error TS2537: Type '{ a
tests/cases/conformance/types/rest/objectRest.ts(44,53): error TS2739: Type '{}' is missing the following properties from type '{ a: number; b: string; }': a, b


==== tests/cases/conformance/types/rest/objectRest.ts (8 errors) ====
==== tests/cases/conformance/types/rest/objectRest.ts (6 errors) ====
var o = { a: 1, b: 'no' }
var { ...clone } = o;
var { a, ...justB } = o;
var { a, b: renamed, ...empty } = o;
var { ['b']: renamed, ...justA } = o;
var { 'b': renamed, ...justA } = o;
var { b: { '0': n, '1': oooo }, ...justA } = o;
~~~
!!! error TS2339: Property '0' does not exist on type 'String'.
~~~
!!! error TS2339: Property '1' does not exist on type 'String'.

let o2 = { c: 'terrible idea?', d: 'yes' };
var { d: renamed, ...d } = o2;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/objectRest.types
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var { 'b': renamed, ...justA } = o;

var { b: { '0': n, '1': oooo }, ...justA } = o;
>b : any
>n : any
>oooo : any
>n : string
>oooo : string
>justA : { a: number; }
>o : { a: number; b: string; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=== tests/cases/conformance/es6/templates/templateStringInIndexExpression.ts ===
`abc${0}abc`[`0`];
>`abc${0}abc`[`0`] : error
>`abc${0}abc`[`0`] : string
>`abc${0}abc` : string
>0 : 0
>`0` : "0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=== tests/cases/conformance/es6/templates/templateStringInIndexExpressionES6.ts ===
`abc${0}abc`[`0`];
>`abc${0}abc`[`0`] : error
>`abc${0}abc`[`0`] : string
>`abc${0}abc` : string
>0 : 0
>`0` : "0"
Expand Down