diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a2b0d4b823e..6bb3e7d9706 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -26599,7 +26599,7 @@ namespace ts { switch (name.parent.kind) { case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - return true; + return isIdentifier(name); default: return isDeclarationName(name); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 98e8e61eef5..79dd86ccb09 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2859,6 +2859,15 @@ Actual: ${stringify(fullActual)}`); } } + public verifyNoDocumentHighlights(startRange: Range) { + this.goToRangeStart(startRange); + const documentHighlights = this.getDocumentHighlightsAtCurrentPosition([this.activeFile.fileName]); + const numHighlights = ts.length(documentHighlights); + if (numHighlights > 0) { + this.raiseError(`verifyNoDocumentHighlights failed - unexpectedly got ${numHighlights} highlights`); + } + } + private verifyDocumentHighlights(expectedRanges: Range[], fileNames: string[] = [this.activeFile.fileName]) { const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || []; @@ -4267,6 +4276,10 @@ namespace FourSlashInterface { this.state.verifyDocumentHighlightsOf(startRange, ranges); } + public noDocumentHighlights(startRange: FourSlash.Range) { + this.state.verifyNoDocumentHighlights(startRange); + } + public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string, tags?: ts.JSDocTagInfo[]) { this.state.verifyCompletionEntryDetails(entryName, text, documentation, kind, tags); } diff --git a/tests/cases/fourslash/documentHighlightInExport1.ts b/tests/cases/fourslash/documentHighlightInExport1.ts new file mode 100644 index 00000000000..bf5bc7cfa94 --- /dev/null +++ b/tests/cases/fourslash/documentHighlightInExport1.ts @@ -0,0 +1,10 @@ +/// + +//// class [|C|] {} +//// [|export|] { [|C|] [|as|] [|D|] }; + +const [classRange, exportKeywordRange, propertyNameRange, asKeywordRange, nameRange] = test.ranges(); +verify.noDocumentHighlights(exportKeywordRange); +verify.documentHighlightsOf(propertyNameRange, [classRange, propertyNameRange, nameRange]); +verify.noDocumentHighlights(asKeywordRange); +verify.documentHighlightsOf(nameRange, [nameRange]); diff --git a/tests/cases/fourslash/findAllRefsInExport1.ts b/tests/cases/fourslash/findAllRefsInExport1.ts new file mode 100644 index 00000000000..02ec901177f --- /dev/null +++ b/tests/cases/fourslash/findAllRefsInExport1.ts @@ -0,0 +1,10 @@ +/// + +//// class C {} +//// /*1*/export { C /*2*/as D }; + +goTo.marker("1"); +verify.noReferences(); + +goTo.marker("2"); +verify.noReferences(); \ No newline at end of file