From 3270a36992d2bf9f319e74c428a78a8dd506678e Mon Sep 17 00:00:00 2001 From: Max Heiber Date: Tue, 28 Aug 2018 22:15:54 -0700 Subject: [PATCH] Fix ambiguous wording of PrivateName access error Signed-off-by: Max Heiber --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../privateNameNotAccessibleOutsideDefiningClass.errors.txt | 4 ++-- .../reference/privateNamesInGenericClasses.errors.txt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1db5c9ef01eaa..662fec7a5897b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index aeba5834bd8c8..8fcc1764a470c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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 }, diff --git a/tests/baselines/reference/privateNameNotAccessibleOutsideDefiningClass.errors.txt b/tests/baselines/reference/privateNameNotAccessibleOutsideDefiningClass.errors.txt index 61b892d67ddc4..904f4729d5ac0 100644 --- a/tests/baselines/reference/privateNameNotAccessibleOutsideDefiningClass.errors.txt +++ b/tests/baselines/reference/privateNameNotAccessibleOutsideDefiningClass.errors.txt @@ -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) ==== @@ -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. \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesInGenericClasses.errors.txt b/tests/baselines/reference/privateNamesInGenericClasses.errors.txt index 82435199292ee..9da803c3ca597 100644 --- a/tests/baselines/reference/privateNamesInGenericClasses.errors.txt +++ b/tests/baselines/reference/privateNamesInGenericClasses.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(10,3): error TS18007: Property '#foo' is only accessible within class 'C' 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' because it has a private name. tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(11,1): error TS2322: Type 'C' is not assignable to type 'C'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(12,1): error TS2322: Type 'C' is not assignable to type 'C'. @@ -17,7 +17,7 @@ tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasse declare let b: C; a.#foo; // OK ~~~~ -!!! error TS18007: Property '#foo' is only accessible within class 'C' because it has a private name. +!!! error TS18007: Property '#foo' is not accessible outside class 'C' because it has a private name. a = b; // Error ~ !!! error TS2322: Type 'C' is not assignable to type 'C'.