From 1c90ef5aad15e9b09a3d8be0d87868347566dc37 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 15 Mar 2017 19:16:37 -0700 Subject: [PATCH] wip-fix resolveEntityName with parenthesizedExpression --- src/compiler/checker.ts | 12 +++++++++--- src/compiler/types.ts | 2 +- ...DeclarationWithPropertyAccessInHeritageClause1.ts | 12 ++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 00498191f2..ab35f15b60 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1511,6 +1511,9 @@ namespace ts { return undefined; } } + else if (name.kind === SyntaxKind.ParenthesizedExpression) { + return getSymbolOfNode(name.expression); + } else { Debug.fail("Unknown entity name kind."); } @@ -21069,7 +21072,6 @@ namespace ts { if (isHeritageClauseElementIdentifier(entityName)) { let meaning = SymbolFlags.None; - // In an interface or class, we're definitely interested in a type. if (entityName.parent.kind === SyntaxKind.ExpressionWithTypeArguments) { meaning = SymbolFlags.Type; @@ -21084,9 +21086,13 @@ namespace ts { } meaning |= SymbolFlags.Alias; - return resolveEntityName(entityName, meaning); + const entityNameSymbol = resolveEntityName(entityName, meaning); + if (entityNameSymbol) { + return entityNameSymbol; + } } - else if (isPartOfExpression(entityName)) { + + if (isPartOfExpression(entityName)) { if (nodeIsMissing(entityName)) { // Missing entity name. return undefined; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86895f3db6..0f183c6b1f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1395,7 +1395,7 @@ namespace ts { multiLine?: boolean; } - export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression; export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; export interface PropertyAccessExpression extends MemberExpression, Declaration { diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts new file mode 100644 index 0000000000..e22bd2351c --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAccessInHeritageClause1.ts @@ -0,0 +1,12 @@ +interface I {} +interface CTor { + new (hour: number, minute: number): I +} +var x: { + B : CTor +}; +class B {} +function foo() { + return {B: B}; +} +class C extends (foo()).B {} \ No newline at end of file