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
Allow 'readonly' only on property and index signature declarations
  • Loading branch information
ahejlsberg committed Jan 19, 2016
commit 01c96868697163cbb4f6f7135a882d14eeaa31e8
9 changes: 3 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10378,7 +10378,7 @@ namespace ts {
}

function isReadonlySymbol(symbol: Symbol): boolean {
if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) {
if (symbol.flags & SymbolFlags.Property) {
return symbol === undefinedSymbol || (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0;
}
if (symbol.flags & SymbolFlags.Accessor) {
Expand Down Expand Up @@ -15786,11 +15786,8 @@ namespace ts {
if (flags & NodeFlags.Readonly) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "readonly");
}
else if (flags & NodeFlags.Async) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "readonly", "async");
}
else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "readonly");
else if (node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.PropertySignature && node.kind !== SyntaxKind.IndexSignature) {
return grammarErrorOnNode(modifier, Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
}
flags |= NodeFlags.Readonly;
lastReadonly = modifier;
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"category": "Error",
"code": 1023
},
"'readonly' modifier can only appear on a property declaration or index signature.": {
"category": "Error",
"code": 1024
},
"Accessibility modifier already seen.": {
"category": "Error",
"code": 1028
Expand Down
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