Skip to content

Readonly properties and index signatures #6532

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
merged 34 commits into from
Jan 27, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b46efc9
Allow modifies on type members + introduce "readonly" modifier
ahejlsberg Jan 14, 2016
07b7008
Accepting new baselines
ahejlsberg Jan 14, 2016
d504357
Check readonly in assignments and type relations
ahejlsberg Jan 16, 2016
8319f2e
Accepting new baselines
ahejlsberg Jan 16, 2016
07763ed
Removing unused function
ahejlsberg Jan 17, 2016
5b233e4
Refactor to introduce IndexInfo type
ahejlsberg Jan 17, 2016
b8cd0e5
Support readonly indexers + include readonly modifier in typeToString
ahejlsberg Jan 18, 2016
17b5899
Fixing fourslash test
ahejlsberg Jan 18, 2016
13f763d
Accepting new baselines
ahejlsberg Jan 18, 2016
2a20e91
Allow assignments to readonly properties in constructors
ahejlsberg Jan 19, 2016
01c9686
Allow 'readonly' only on property and index signature declarations
ahejlsberg Jan 19, 2016
d3be38e
Updating error messages
ahejlsberg Jan 19, 2016
723475b
Accepting new baselines
ahejlsberg Jan 19, 2016
a499607
Merge branch 'master' into readonlyMembers
ahejlsberg Jan 19, 2016
dc8ab95
Chaning "read-write" to "writable" in error messages
ahejlsberg Jan 19, 2016
4abf717
Accepting new baselines
ahejlsberg Jan 19, 2016
cac3a32
Add ReadonlyArray<T> to core.d.ts
ahejlsberg Jan 19, 2016
8bb00fe
Consider ReadonlyArray<T> an array-like type
ahejlsberg Jan 19, 2016
fc6947b
Make get only accessor compatible with writable property in type rela…
ahejlsberg Jan 21, 2016
9562353
Fixing fourslash test
ahejlsberg Jan 21, 2016
b6f43e6
Accepting new baselines
ahejlsberg Jan 21, 2016
fac1bf6
Disallow assigments to exported variables from external modules
ahejlsberg Jan 22, 2016
e506378
Accepting new baselines
ahejlsberg Jan 22, 2016
ee0060b
No readonly checks in type relationships + No assignments through nam…
ahejlsberg Jan 23, 2016
7405a4b
Accepting new baselines
ahejlsberg Jan 23, 2016
49dd54e
Include readonly in type equality checks + Treat more symbols as read…
ahejlsberg Jan 24, 2016
ea4e3af
Fix tests
ahejlsberg Jan 24, 2016
c78ee72
Accepting new baselines
ahejlsberg Jan 24, 2016
c826a90
Merge branch 'master' into readonlyMembers
ahejlsberg Jan 24, 2016
7561642
Adding const/readonly to core.d.ts and es6.d.ts
ahejlsberg Jan 24, 2016
0b1f0d8
Accepting new baselines
ahejlsberg Jan 24, 2016
77d174a
Adding tests
ahejlsberg Jan 25, 2016
da107fe
Accepting new baselines
ahejlsberg Jan 25, 2016
cbb195b
Renumbering NodeFlags to start at 1 << 0
ahejlsberg Jan 27, 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
Accepting new baselines
  • Loading branch information
ahejlsberg committed Jan 14, 2016
commit 07b7008ba6db8a0872f66bc1b14955525e73c594
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts(3,5): error TS1131: Property or signature expected.
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts(4,5): error TS1131: Property or signature expected.
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts(5,5): error TS1131: Property or signature expected.
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts(3,5): error TS1070: 'public' modifier cannot appear on a type member.
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts(4,5): error TS1070: 'private' modifier cannot appear on a type member.
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts(5,5): error TS1070: 'protected' modifier cannot appear on a type member.


==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithAccessibilityModifiers.ts (3 errors) ====
// Errors
interface Foo {
public a: any;
~~~~~~
!!! error TS1131: Property or signature expected.
!!! error TS1070: 'public' modifier cannot appear on a type member.
private b: any;
~~~~~~~
!!! error TS1131: Property or signature expected.
!!! error TS1070: 'private' modifier cannot appear on a type member.
protected c: any;
~~~~~~~~~
!!! error TS1131: Property or signature expected.
!!! error TS1070: 'protected' modifier cannot appear on a type member.
}
22 changes: 8 additions & 14 deletions tests/baselines/reference/interfaceWithPrivateMember.errors.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(5,5): error TS1131: Property or signature expected.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(9,5): error TS1131: Property or signature expected.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,5): error TS1131: Property or signature expected.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,16): error TS2304: Cannot find name 'string'.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(14,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(5,5): error TS1070: 'private' modifier cannot appear on a type member.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(9,5): error TS1070: 'private' modifier cannot appear on a type member.
tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts(13,5): error TS1070: 'private' modifier cannot appear on a type member.


==== tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts (5 errors) ====
==== tests/cases/conformance/types/namedTypes/interfaceWithPrivateMember.ts (3 errors) ====

// interfaces do not permit private members, these are errors

interface I {
private x: string;
~~~~~~~
!!! error TS1131: Property or signature expected.
!!! error TS1070: 'private' modifier cannot appear on a type member.
}

interface I2<T> {
private y: T;
~~~~~~~
!!! error TS1131: Property or signature expected.
!!! error TS1070: 'private' modifier cannot appear on a type member.
}

var x: {
private y: string;
~~~~~~~
!!! error TS1131: Property or signature expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
}
~
!!! error TS1128: Declaration or statement expected.
!!! error TS1070: 'private' modifier cannot appear on a type member.
}
1 change: 0 additions & 1 deletion tests/baselines/reference/interfaceWithPrivateMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ var x: {
//// [interfaceWithPrivateMember.js]
// interfaces do not permit private members, these are errors
var x;
y: string;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts(2,3): error TS1145: Modifiers not permitted on index signature members.
tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts(2,3): error TS1071: 'public' modifier cannot appear on an index signature.


==== tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts (1 errors) ====
interface I {
public [a: string]: number;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'public' modifier cannot appear on an index signature.
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts(2,11): error TS1030: 'static' modifier already seen.
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts(2,4): error TS1071: 'static' modifier cannot appear on an index signature.


==== tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts (1 errors) ====
class C {
static static [x: string]: string;
~~~~~~
!!! error TS1030: 'static' modifier already seen.
~~~~~~
!!! error TS1071: 'static' modifier cannot appear on an index signature.
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration6.ts(2,4): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration6.ts(2,4): error TS1071: 'static' modifier cannot appear on an index signature.


==== tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration6.ts (1 errors) ====
class C {
static [x: string]: string;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'static' modifier cannot appear on an index signature.
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration7.ts(2,4): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration7.ts(2,4): error TS1071: 'public' modifier cannot appear on an index signature.


==== tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration7.ts (1 errors) ====
class C {
public [x: string]: string;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'public' modifier cannot appear on an index signature.
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration8.ts(2,4): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration8.ts(2,4): error TS1071: 'private' modifier cannot appear on an index signature.


==== tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration8.ts (1 errors) ====
class C {
private [x: string]: string;
~~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'private' modifier cannot appear on an index signature.
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration9.ts(2,4): error TS1031: 'export' modifier cannot appear on a class element.
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration9.ts(2,4): error TS1071: 'export' modifier cannot appear on an index signature.


==== tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration9.ts (1 errors) ====
class C {
export [x: string]: string;
~~~~~~
!!! error TS1031: 'export' modifier cannot appear on a class element.
!!! error TS1071: 'export' modifier cannot appear on an index signature.
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnPropertySignature1.ts(2,5): error TS1131: Property or signature expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnPropertySignature1.ts(2,5): error TS1070: 'public' modifier cannot appear on a type member.


==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserModifierOnPropertySignature1.ts (1 errors) ====
interface Foo{
public biz;
~~~~~~
!!! error TS1131: Property or signature expected.
!!! error TS1070: 'public' modifier cannot appear on a type member.
}

6 changes: 3 additions & 3 deletions tests/baselines/reference/parserSymbolIndexer3.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts(2,13): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts(2,5): error TS1071: 'static' modifier cannot appear on an index signature.


==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts (1 errors) ====
class C {
static [s: symbol]: string;
~
!!! error TS1023: An index signature parameter type must be 'string' or 'number'.
~~~~~~
!!! error TS1071: 'static' modifier cannot appear on an index signature.
}
12 changes: 6 additions & 6 deletions tests/baselines/reference/privateIndexer.errors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(4,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(8,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(12,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(4,5): error TS1071: 'private' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(8,5): error TS1071: 'private' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(12,5): error TS1071: 'private' modifier cannot appear on an index signature.


==== tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts (3 errors) ====
Expand All @@ -9,17 +9,17 @@ tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer.ts(12,5):
class C {
private [x: string]: string;
~~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'private' modifier cannot appear on an index signature.
}

class D {
private [x: number]: string;
~~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'private' modifier cannot appear on an index signature.
}

class E<T> {
private [x: string]: T;
~~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'private' modifier cannot appear on an index signature.
}
12 changes: 6 additions & 6 deletions tests/baselines/reference/publicIndexer.errors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(4,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(8,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(12,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(4,5): error TS1071: 'public' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(8,5): error TS1071: 'public' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(12,5): error TS1071: 'public' modifier cannot appear on an index signature.


==== tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts (3 errors) ====
Expand All @@ -9,17 +9,17 @@ tests/cases/conformance/classes/indexMemberDeclarations/publicIndexer.ts(12,5):
class C {
public [x: string]: string;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'public' modifier cannot appear on an index signature.
}

class D {
public [x: number]: string;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'public' modifier cannot appear on an index signature.
}

class E<T> {
public [x: string]: T;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'public' modifier cannot appear on an index signature.
}
6 changes: 3 additions & 3 deletions tests/baselines/reference/staticAsIdentifier.errors.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
tests/cases/compiler/staticAsIdentifier.ts(2,12): error TS1030: 'static' modifier already seen.
tests/cases/compiler/staticAsIdentifier.ts(2,5): error TS1071: 'static' modifier cannot appear on an index signature.


==== tests/cases/compiler/staticAsIdentifier.ts (1 errors) ====
class C {
static static
~~~~~~
!!! error TS1030: 'static' modifier already seen.
~~~~~~
!!! error TS1071: 'static' modifier cannot appear on an index signature.
[x: string]: string;
}
4 changes: 2 additions & 2 deletions tests/baselines/reference/staticIndexer.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests/cases/compiler/staticIndexer.ts(2,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/compiler/staticIndexer.ts(2,5): error TS1071: 'static' modifier cannot appear on an index signature.


==== tests/cases/compiler/staticIndexer.ts (1 errors) ====
class C {
static [s: string]: number;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'static' modifier cannot appear on an index signature.
}
12 changes: 6 additions & 6 deletions tests/baselines/reference/staticIndexers.errors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(4,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(8,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(12,5): error TS1145: Modifiers not permitted on index signature members.
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(4,5): error TS1071: 'static' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(8,5): error TS1071: 'static' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(12,5): error TS1071: 'static' modifier cannot appear on an index signature.
tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(12,25): error TS2302: Static members cannot reference class type parameters.


Expand All @@ -10,19 +10,19 @@ tests/cases/conformance/classes/indexMemberDeclarations/staticIndexers.ts(12,25)
class C {
static [x: string]: string;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'static' modifier cannot appear on an index signature.
}

class D {
static [x: number]: string;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'static' modifier cannot appear on an index signature.
}

class E<T> {
static [x: string]: T;
~~~~~~
!!! error TS1145: Modifiers not permitted on index signature members.
!!! error TS1071: 'static' modifier cannot appear on an index signature.
~
!!! error TS2302: Static members cannot reference class type parameters.
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy