From 6ea2278c7a37f0f6eb21f00d0689ba7dd8e61ff4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 23 Aug 2018 11:27:03 -0700 Subject: [PATCH] Get symbol at location for class expressions/keywords (#26636) * getSymbolAtLocation understands class expressions Previously it did not. * Update baselines --- src/compiler/checker.ts | 1 + tests/cases/fourslash/quickInfoClassKeyword.ts | 8 ++++++++ tests/cases/fourslash/quickInfoInvalidLocations.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoClassKeyword.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 269f8b26f0a..0509d53c9b3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27269,6 +27269,7 @@ namespace ts { case SyntaxKind.DefaultKeyword: case SyntaxKind.FunctionKeyword: case SyntaxKind.EqualsGreaterThanToken: + case SyntaxKind.ClassKeyword: return getSymbolOfNode(node.parent); case SyntaxKind.ImportType: return isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; diff --git a/tests/cases/fourslash/quickInfoClassKeyword.ts b/tests/cases/fourslash/quickInfoClassKeyword.ts new file mode 100644 index 00000000000..8a132cf8be9 --- /dev/null +++ b/tests/cases/fourslash/quickInfoClassKeyword.ts @@ -0,0 +1,8 @@ +/// + +////[1].forEach(cla/*1*/ss {}); +////[1].forEach(cla/*2*/ss OK{}); + +verify.quickInfoAt("1", "(local class) (Anonymous class)"); +verify.quickInfoAt("2", "(local class) OK"); + diff --git a/tests/cases/fourslash/quickInfoInvalidLocations.ts b/tests/cases/fourslash/quickInfoInvalidLocations.ts index 396fac67c97..97df6ebd146 100644 --- a/tests/cases/fourslash/quickInfoInvalidLocations.ts +++ b/tests/cases/fourslash/quickInfoInvalidLocations.ts @@ -8,7 +8,7 @@ //// property: string; /////*invalid2*/} //// -////cl/*invalid3*/ass bar imple/*invalid4*/ments IFoo { +////class bar imple/*invalid4*/ments IFoo { //// constructor( /*invalid5*/ ) { //// //// }