Skip to content

Commit

Permalink
Fix ambiguous wording of PrivateName access error
Browse files Browse the repository at this point in the history
Signed-off-by: Max Heiber <max.heiber@gmail.com>
  • Loading branch information
mheiber committed Aug 29, 2018
1 parent bd08ec0 commit 3270a36
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17867,7 +17867,7 @@ namespace ts {
if (node.kind === SyntaxKind.PropertyAccessExpression && isPrivateName(node.name)) {
const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)!)!;
if (!isNodeWithinClass(node, declaringClassDeclaration)) {
error(errorNode, Diagnostics.Property_0_is_only_accessible_within_class_1_because_it_has_a_private_name, symbolToString(prop), typeToString(getDeclaringClass(prop)!));
error(errorNode, Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_name, symbolToString(prop), typeToString(getDeclaringClass(prop)!));
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4178,7 +4178,7 @@
"category": "Error",
"code": 18006
},
"Property '{0}' is only accessible within class '{1}' because it has a private name.": {
"Property '{0}' is not accessible outside class '{1}' because it has a private name.": {
"category": "Error",
"code": 18007
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/conformance/classes/members/privateNames/privateNameNotAccessibleOutsideDefiningClass.ts(5,9): error TS18007: Property '#foo' is only accessible within class 'A' because it has a private name.
tests/cases/conformance/classes/members/privateNames/privateNameNotAccessibleOutsideDefiningClass.ts(5,9): error TS18007: Property '#foo' is not accessible outside class 'A' because it has a private name.


==== tests/cases/conformance/classes/members/privateNames/privateNameNotAccessibleOutsideDefiningClass.ts (1 errors) ====
Expand All @@ -8,5 +8,5 @@ tests/cases/conformance/classes/members/privateNames/privateNameNotAccessibleOut

new A().#foo = 4; // Error
~~~~
!!! error TS18007: Property '#foo' is only accessible within class 'A' because it has a private name.
!!! error TS18007: Property '#foo' is not accessible outside class 'A' because it has a private name.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(10,3): error TS18007: Property '#foo' is only accessible within class 'C<T>' because it has a private name.
tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(10,3): error TS18007: Property '#foo' is not accessible outside class 'C<T>' because it has a private name.
tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(11,1): error TS2322: Type 'C<string>' is not assignable to type 'C<number>'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(12,1): error TS2322: Type 'C<number>' is not assignable to type 'C<string>'.
Expand All @@ -17,7 +17,7 @@ tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasse
declare let b: C<string>;
a.#foo; // OK
~~~~
!!! error TS18007: Property '#foo' is only accessible within class 'C<T>' because it has a private name.
!!! error TS18007: Property '#foo' is not accessible outside class 'C<T>' because it has a private name.
a = b; // Error
~
!!! error TS2322: Type 'C<string>' is not assignable to type 'C<number>'.
Expand Down

0 comments on commit 3270a36

Please sign in to comment.