Fix #51437 Duplicate "Duplicate identifier" errors (#51594)

* retroactive approach to remove duplicate diagnostics

* use code instead of messageText, update test

* use existing de-dupe function

* rename test and baselines

* add fourslash test for better assertion of fix

* review feedback: move deduplicate to getDiagnosticsHelper

* accept baseline with sorted diagnostics

* remove newline
This commit is contained in:
George Manning 2022-12-09 03:21:41 +00:00 committed by GitHub
parent e087992134
commit 65bf850a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 15 deletions

View File

@ -2639,7 +2639,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken | undefined) => readonly T[],
cancellationToken: CancellationToken | undefined): readonly T[] {
if (sourceFile) {
return getDiagnostics(sourceFile, cancellationToken);
return sortAndDeduplicateDiagnostics(getDiagnostics(sourceFile, cancellationToken));
}
return sortAndDeduplicateDiagnostics(flatMap(program.getSourceFiles(), sourceFile => {
if (cancellationToken) {

View File

@ -118,19 +118,6 @@ FsWatchesRecursive::
Info 15 [00:00:34.000] response:
{
"response": [
{
"start": {
"line": 2,
"offset": 29
},
"end": {
"line": 2,
"offset": 30
},
"text": "Cannot find name 'y'.",
"code": 2304,
"category": "error"
},
{
"start": {
"line": 1,
@ -143,6 +130,19 @@ Info 15 [00:00:34.000] response:
"text": "File '/a/b/commonFile2.ts' not found.",
"code": 6053,
"category": "error"
},
{
"start": {
"line": 2,
"offset": 29
},
"end": {
"line": 2,
"offset": 30
},
"text": "Cannot find name 'y'.",
"code": 2304,
"category": "error"
}
],
"responseRequired": true

View File

@ -11,7 +11,7 @@
verify.codeFix({
description: "Infer parameter types from usage",
index: 4,
index: 3,
newFileContent:
`/**
* @param {number} a

View File

@ -0,0 +1,12 @@
/// <reference path="./fourslash.ts" />
//// class X {
//// foo() {
//// return 1;
//// }
//// get foo() {
//// return 1;
//// }
//// }
verify.numberOfErrorsInCurrentFile(2);