Fix #5651: Get the correct meaning for expressions in extends clauses

This commit is contained in:
Mohamed Hegazy 2016-03-03 21:47:11 -08:00
parent baa040115e
commit c98c763243
5 changed files with 129 additions and 1 deletions

View File

@ -1642,7 +1642,7 @@ namespace ts {
function isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult {
// get symbol of the first identifier of the entityName
let meaning: SymbolFlags;
if (entityName.parent.kind === SyntaxKind.TypeQuery) {
if (entityName.parent.kind === SyntaxKind.TypeQuery || isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) {
// Typeof value
meaning = SymbolFlags.Value | SymbolFlags.ExportValue;
}

View File

@ -0,0 +1,49 @@
//// [declarationEmit_expressionInExtends.ts]
var x: {
new<T>(s: any): Q;
}
class Q {
s: string;
}
class B extends x<string> {
}
var q: B;
q.s;
//// [declarationEmit_expressionInExtends.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var x;
var Q = (function () {
function Q() {
}
return Q;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
}(x));
var q;
q.s;
//// [declarationEmit_expressionInExtends.d.ts]
declare var x: {
new <T>(s: any): Q;
};
declare class Q {
s: string;
}
declare class B extends x<string> {
}
declare var q: B;

View File

@ -0,0 +1,32 @@
=== tests/cases/compiler/declarationEmit_expressionInExtends.ts ===
var x: {
>x : Symbol(x, Decl(declarationEmit_expressionInExtends.ts, 1, 3))
new<T>(s: any): Q;
>T : Symbol(T, Decl(declarationEmit_expressionInExtends.ts, 2, 8))
>s : Symbol(s, Decl(declarationEmit_expressionInExtends.ts, 2, 11))
>Q : Symbol(Q, Decl(declarationEmit_expressionInExtends.ts, 3, 1))
}
class Q {
>Q : Symbol(Q, Decl(declarationEmit_expressionInExtends.ts, 3, 1))
s: string;
>s : Symbol(s, Decl(declarationEmit_expressionInExtends.ts, 5, 9))
}
class B extends x<string> {
>B : Symbol(B, Decl(declarationEmit_expressionInExtends.ts, 7, 1))
>x : Symbol(x, Decl(declarationEmit_expressionInExtends.ts, 1, 3))
}
var q: B;
>q : Symbol(q, Decl(declarationEmit_expressionInExtends.ts, 12, 3))
>B : Symbol(B, Decl(declarationEmit_expressionInExtends.ts, 7, 1))
q.s;
>q.s : Symbol(Q.s, Decl(declarationEmit_expressionInExtends.ts, 5, 9))
>q : Symbol(q, Decl(declarationEmit_expressionInExtends.ts, 12, 3))
>s : Symbol(Q.s, Decl(declarationEmit_expressionInExtends.ts, 5, 9))

View File

@ -0,0 +1,32 @@
=== tests/cases/compiler/declarationEmit_expressionInExtends.ts ===
var x: {
>x : new <T>(s: any) => Q
new<T>(s: any): Q;
>T : T
>s : any
>Q : Q
}
class Q {
>Q : Q
s: string;
>s : string
}
class B extends x<string> {
>B : B
>x : Q
}
var q: B;
>q : B
>B : B
q.s;
>q.s : string
>q : B
>s : string

View File

@ -0,0 +1,15 @@
// @declaration: true
var x: {
new<T>(s: any): Q;
}
class Q {
s: string;
}
class B extends x<string> {
}
var q: B;
q.s;