From 8e96c2282b835eecec99f3cf8a5cf38a4274641c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 23 Dec 2019 17:03:05 -0800 Subject: [PATCH 1/4] Give an actionable elaboration. --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f4f1884836a62..f707196f27591 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18931,7 +18931,7 @@ namespace ts { return getTypeOfSymbol(symbol); } if (diagnostic && symbol.valueDeclaration) { - addRelatedInfo(diagnostic, createDiagnosticForNode(symbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(symbol))); + addRelatedInfo(diagnostic, createDiagnosticForNode(symbol.valueDeclaration, Diagnostics._0_must_be_declared_with_an_explicit_type_annotation, symbolToString(symbol))); } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index eea25393faf7e..35f53fef5a7f2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2795,6 +2795,10 @@ "category": "Error", "code": 2781 }, + "'{0}' must be declared with an explicit type annotation.": { + "category": "Message", + "code": 2782 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From 2fb6d5c86d9ff4f27389fbf6a30323ca34eba13b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 23 Dec 2019 17:03:22 -0800 Subject: [PATCH 2/4] Accepted baselines. --- tests/baselines/reference/assertionTypePredicates1.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/assertionTypePredicates1.errors.txt b/tests/baselines/reference/assertionTypePredicates1.errors.txt index cefd25aa13944..fff0263d0cdbe 100644 --- a/tests/baselines/reference/assertionTypePredicates1.errors.txt +++ b/tests/baselines/reference/assertionTypePredicates1.errors.txt @@ -184,7 +184,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(149,5): error TS assert(typeof x === "string"); // Error ~~~~~~ !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -!!! related TS2728 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' is declared here. +!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' must be declared with an explicit type annotation. const a = [assert]; a[0](typeof x === "string"); // Error ~~~~ @@ -193,7 +193,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(149,5): error TS t1.assert(typeof x === "string"); // Error ~~~~~~~~~ !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -!!! related TS2728 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:148:11: 't1' is declared here. +!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:148:11: 't1' must be declared with an explicit type annotation. const t2: Test = new Test(); t2.assert(typeof x === "string"); } From 696fb6590a8a49bffd0e09eec37e8624b425c015 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 23 Dec 2019 17:10:28 -0800 Subject: [PATCH 3/4] Less words. --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f707196f27591..1760bd234647d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18931,7 +18931,7 @@ namespace ts { return getTypeOfSymbol(symbol); } if (diagnostic && symbol.valueDeclaration) { - addRelatedInfo(diagnostic, createDiagnosticForNode(symbol.valueDeclaration, Diagnostics._0_must_be_declared_with_an_explicit_type_annotation, symbolToString(symbol))); + addRelatedInfo(diagnostic, createDiagnosticForNode(symbol.valueDeclaration, Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol))); } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 35f53fef5a7f2..64fed57eb689a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2795,7 +2795,7 @@ "category": "Error", "code": 2781 }, - "'{0}' must be declared with an explicit type annotation.": { + "'{0}' needs an explicit type annotation.": { "category": "Message", "code": 2782 }, From ce88cf157a0c1faa0db74f6a7a3585e5576588a9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 23 Dec 2019 17:11:37 -0800 Subject: [PATCH 4/4] Accepted baselines. --- tests/baselines/reference/assertionTypePredicates1.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/assertionTypePredicates1.errors.txt b/tests/baselines/reference/assertionTypePredicates1.errors.txt index fff0263d0cdbe..9b23370a4c91b 100644 --- a/tests/baselines/reference/assertionTypePredicates1.errors.txt +++ b/tests/baselines/reference/assertionTypePredicates1.errors.txt @@ -184,7 +184,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(149,5): error TS assert(typeof x === "string"); // Error ~~~~~~ !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' must be declared with an explicit type annotation. +!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' needs an explicit type annotation. const a = [assert]; a[0](typeof x === "string"); // Error ~~~~ @@ -193,7 +193,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(149,5): error TS t1.assert(typeof x === "string"); // Error ~~~~~~~~~ !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:148:11: 't1' must be declared with an explicit type annotation. +!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:148:11: 't1' needs an explicit type annotation. const t2: Test = new Test(); t2.assert(typeof x === "string"); }