diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a9616e8edce..9af6271a58a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -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) { diff --git a/tests/baselines/reference/tsserver/projects/handles-the-missing-files-added-with-tripleslash-ref.js b/tests/baselines/reference/tsserver/projects/handles-the-missing-files-added-with-tripleslash-ref.js index 5072507f562..52c79c212ef 100644 --- a/tests/baselines/reference/tsserver/projects/handles-the-missing-files-added-with-tripleslash-ref.js +++ b/tests/baselines/reference/tsserver/projects/handles-the-missing-files-added-with-tripleslash-ref.js @@ -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 diff --git a/tests/cases/fourslash/codeFixInferFromUsageMultipleParametersJS.ts b/tests/cases/fourslash/codeFixInferFromUsageMultipleParametersJS.ts index d82700c1709..4117c520a3e 100644 --- a/tests/cases/fourslash/codeFixInferFromUsageMultipleParametersJS.ts +++ b/tests/cases/fourslash/codeFixInferFromUsageMultipleParametersJS.ts @@ -11,7 +11,7 @@ verify.codeFix({ description: "Infer parameter types from usage", - index: 4, + index: 3, newFileContent: `/** * @param {number} a diff --git a/tests/cases/fourslash/deduplicateDuplicateMergedBindCheckErrors.ts b/tests/cases/fourslash/deduplicateDuplicateMergedBindCheckErrors.ts new file mode 100644 index 00000000000..6778ddc56d7 --- /dev/null +++ b/tests/cases/fourslash/deduplicateDuplicateMergedBindCheckErrors.ts @@ -0,0 +1,12 @@ +/// + +//// class X { +//// foo() { +//// return 1; +//// } +//// get foo() { +//// return 1; +//// } +//// } + +verify.numberOfErrorsInCurrentFile(2);