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

Static types for dynamically named properties #11929

Merged
merged 21 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ad88109
Initial implementation of 'keyof T' type operator
ahejlsberg Oct 24, 2016
07478aa
Introduce PropertyNameType
ahejlsberg Oct 25, 2016
c21592e
Initial implementation of 'T[K]' property access types
ahejlsberg Oct 25, 2016
e7cfbfe
Support parametric property access expressions + some renaming
ahejlsberg Oct 26, 2016
4b50ef3
Consider index signatures in type produced by 'keyof T'
ahejlsberg Oct 27, 2016
ece1f19
Refactor getIndexedAccessType to be reusable from checkIndexedAccess
ahejlsberg Oct 27, 2016
8d87971
Minor fixes
ahejlsberg Oct 28, 2016
5515dce
Improved error messages for invalid assignments to identifiers
ahejlsberg Oct 30, 2016
550be9c
Accept new baselines
ahejlsberg Oct 30, 2016
6c20533
Improved error messages for invalid assignments to properties
ahejlsberg Oct 31, 2016
88961cd
Accept new baselines
ahejlsberg Oct 31, 2016
2f34f7c
Improve more error messages
ahejlsberg Oct 31, 2016
f293744
Accept new baselines
ahejlsberg Oct 31, 2016
f9e2085
Unify checking of indexed access expressions and indexed access types
ahejlsberg Oct 31, 2016
03f8403
Accept new baselines
ahejlsberg Oct 31, 2016
8d9356f
Accept additional baselines
ahejlsberg Oct 31, 2016
6b28d21
Merge branch 'master' into keyoftypes
ahejlsberg Oct 31, 2016
41c2054
Improve unification by moving more logic to getIndexedAccessType
ahejlsberg Nov 1, 2016
663985e
Fix 'keyof any' to produce 'string | number'
ahejlsberg Nov 1, 2016
70fc25a
Minor fixes
ahejlsberg Nov 2, 2016
4bbe29a
Adding tests
ahejlsberg Nov 2, 2016
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 Oct 31, 2016
commit 88961cd164ff3c68383ebc1aad0b2c8f4b642b71
6 changes: 3 additions & 3 deletions tests/baselines/reference/abstractPropertyNegative.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstra
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class.
tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected.
tests/cases/compiler/abstractPropertyNegative.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/abstractPropertyNegative.ts(19,3): error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
Types of property 'num' are incompatible.
Type 'string' is not assignable to type 'number'.
Expand Down Expand Up @@ -58,8 +58,8 @@ tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors
}
let c = new C();
c.ro = "error: lhs of assignment can't be readonly";
~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~
!!! error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.

abstract class WrongTypeProperty {
abstract num: number;
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/assignToEnum.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/compiler/assignToEnum.ts(2,1): error TS2539: Cannot assign to 'A' because it is not a variable.
tests/cases/compiler/assignToEnum.ts(3,1): error TS2539: Cannot assign to 'A' because it is not a variable.
tests/cases/compiler/assignToEnum.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/assignToEnum.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/assignToEnum.ts(4,3): error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
tests/cases/compiler/assignToEnum.ts(5,3): error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.


==== tests/cases/compiler/assignToEnum.ts (4 errors) ====
Expand All @@ -13,10 +13,10 @@ tests/cases/compiler/assignToEnum.ts(5,1): error TS2450: Left-hand side of assig
~
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
A.foo = 1; // invalid LHS
~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
A.foo = A.bar; // invalid LHS
~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.


6 changes: 3 additions & 3 deletions tests/baselines/reference/assignments.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(11,1): error TS2304: Cannot find name 'M'.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,3): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2693: 'I' only refers to a type, but is being used as a value here.

Expand Down Expand Up @@ -31,8 +31,8 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er
~
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
E.A = null; // OK per spec, Error per implementation (509581)
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.

function fn() { }
fn = null; // Should be error
Expand Down
102 changes: 51 additions & 51 deletions tests/baselines/reference/constDeclarations-access3.errors.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
tests/cases/compiler/constDeclarations-access3.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(21,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(22,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(24,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(26,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(16,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(19,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(22,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.


Expand All @@ -27,58 +27,58 @@ tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand

// Errors
M.x = 1;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x += 2;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x -= 3;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x *= 4;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x /= 5;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x %= 6;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x <<= 7;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x >>= 8;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x >>>= 9;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x &= 10;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x |= 11;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x ^= 12;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.

M.x++;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x--;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++M.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
--M.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.

++((M.x));
~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.

M["x"] = 0;
~~~~~~
Expand Down
Loading