Fix #4159: look up the type alias paramter within the context of the parent type alias declaration

This commit is contained in:
Mohamed Hegazy 2015-08-06 16:43:15 -07:00
parent fbba50b312
commit d58ec43b3f
5 changed files with 37 additions and 0 deletions

View File

@ -750,6 +750,8 @@ namespace ts {
}
function writeTypeAliasDeclaration(node: TypeAliasDeclaration) {
let prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
emitJsDocComments(node);
emitModuleElementDeclarationFlags(node);
write("type ");
@ -759,6 +761,7 @@ namespace ts {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError);
write(";");
writeLine();
enclosingDeclaration = prevEnclosingDeclaration;
function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
return {

View File

@ -0,0 +1,13 @@
//// [typeAliasDeclarationEmit2.ts]
export type A<a> = { value: a };
//// [typeAliasDeclarationEmit2.js]
define(["require", "exports"], function (require, exports) {
});
//// [typeAliasDeclarationEmit2.d.ts]
export declare type A<a> = {
value: a;
};

View File

@ -0,0 +1,8 @@
=== tests/cases/compiler/typeAliasDeclarationEmit2.ts ===
export type A<a> = { value: a };
>A : Symbol(A, Decl(typeAliasDeclarationEmit2.ts, 0, 0))
>a : Symbol(a, Decl(typeAliasDeclarationEmit2.ts, 1, 14))
>value : Symbol(value, Decl(typeAliasDeclarationEmit2.ts, 1, 20))
>a : Symbol(a, Decl(typeAliasDeclarationEmit2.ts, 1, 14))

View File

@ -0,0 +1,8 @@
=== tests/cases/compiler/typeAliasDeclarationEmit2.ts ===
export type A<a> = { value: a };
>A : { value: a; }
>a : a
>value : a
>a : a

View File

@ -0,0 +1,5 @@
// @target: ES5
// @module: AMD
// @declaration: true
export type A<a> = { value: a };