-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Support for protected members in classes #688
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
Changes from 1 commit
ce6b623
4aa04a9
08188b0
c990c42
ddfe28d
b5b0777
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -544,15 +544,15 @@ | |
"category": "Error", | ||
"code": 2324 | ||
}, | ||
"Private property '{0}' cannot be reimplemented.": { | ||
"Property '{0}' is private in type '{1}' but not in type '{2}'.": { | ||
"category": "Error", | ||
"code": 2325 | ||
}, | ||
"Types of property '{0}' are incompatible:": { | ||
"category": "Error", | ||
"code": 2326 | ||
}, | ||
"Required property '{0}' cannot be reimplemented with optional property in '{1}'.": { | ||
"Property '{0}' is optional in type '{1}' but required in type '{2}'.": { | ||
"category": "Error", | ||
"code": 2327 | ||
}, | ||
|
@@ -604,7 +604,7 @@ | |
"category": "Error", | ||
"code": 2339 | ||
}, | ||
"Only public methods of the base class are accessible via the 'super' keyword": { | ||
"Only public and protected methods of the base class are accessible via the 'super' keyword": { | ||
"category": "Error", | ||
"code": 2340 | ||
}, | ||
|
@@ -784,7 +784,7 @@ | |
"category": "Error", | ||
"code": 2384 | ||
}, | ||
"Overload signatures must all be public or private.": { | ||
"Overload signatures must all be public, private or protected.": { | ||
"category": "Error", | ||
"code": 2385 | ||
}, | ||
|
@@ -1012,7 +1012,18 @@ | |
"category": "Error", | ||
"code": 2441 | ||
}, | ||
|
||
"Types have separate declarations of a private property '{0}'.": { | ||
"category": "Error", | ||
"code": 2442 | ||
}, | ||
"Property '{0}' is protected but type '{1}' is not derived from type '{2}'.": { | ||
"category": "Error", | ||
"code": 2443 | ||
}, | ||
"Property '{0}' is protected in type '{1}' but public in type '{2}'.": { | ||
"category": "Error", | ||
"code": 2444 | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure indentation is consistent here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what's going on, indentation is fine in the actual file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe try opening it in notepad? Visual studio might interpret tabs differently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure there are absolutely no tabs here. |
||
|
||
"Import declaration '{0}' is using private name '{1}'.": { | ||
"category": "Error", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1431,7 +1431,7 @@ module ts { | |
|
||
function emitParameterPropertyAssignments(node: ConstructorDeclaration) { | ||
forEach(node.parameters, param => { | ||
if (param.flags & (NodeFlags.Public | NodeFlags.Private)) { | ||
if (param.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) { | ||
writeLine(); | ||
emitStart(param); | ||
emitStart(param.name); | ||
|
@@ -2368,12 +2368,18 @@ module ts { | |
if (node.flags & NodeFlags.Private) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these seem repeated, I would move them before the if statement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never mind. |
||
write("private "); | ||
} | ||
else if (node.flags & NodeFlags.Protected) { | ||
write("protected "); | ||
} | ||
write("static "); | ||
} | ||
else { | ||
if (node.flags & NodeFlags.Private) { | ||
write("private "); | ||
} | ||
else if (node.flags & NodeFlags.Protected) { | ||
write("protected "); | ||
} | ||
// If the node is parented in the current source file we need to emit export declare or just export | ||
else if (node.parent === currentSourceFile) { | ||
// If the node is exported | ||
|
@@ -2630,7 +2636,7 @@ module ts { | |
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) { | ||
if (constructorDeclaration) { | ||
forEach(constructorDeclaration.parameters, param => { | ||
if (param.flags & (NodeFlags.Public | NodeFlags.Private)) { | ||
if (param.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) { | ||
emitPropertyDeclaration(param); | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,12 +232,13 @@ module ts { | |
Rest = 0x00000008, // Parameter | ||
Public = 0x00000010, // Property/Method | ||
Private = 0x00000020, // Property/Method | ||
Static = 0x00000040, // Property/Method | ||
MultiLine = 0x00000080, // Multi-line array or object literal | ||
Synthetic = 0x00000100, // Synthetic node (for full fidelity) | ||
DeclarationFile = 0x00000200, // Node is a .d.ts file | ||
Protected = 0x00000040, // Property/Method | ||
Static = 0x00000080, // Property/Method | ||
MultiLine = 0x00000100, // Multi-line array or object literal | ||
Synthetic = 0x00000200, // Synthetic node (for full fidelity) | ||
DeclarationFile = 0x00000400, // Node is a .d.ts file | ||
|
||
Modifier = Export | Ambient | Public | Private | Static | ||
Modifier = Export | Ambient | Public | Private | Protected | Static | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @mhegazy added a flag for accessibility modifiers. Can you check with him, and add Protected to that set too? |
||
} | ||
|
||
export interface Node extends TextRange { | ||
|
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.
I have recently added NodeFlags.AccessibilityModifier, a merge should bring it to your branch