Fix #4194: emit type paramters in type alias declaration

This commit is contained in:
Mohamed Hegazy 2015-08-06 16:23:08 -07:00
parent ba7759227b
commit fbba50b312
6 changed files with 50 additions and 2 deletions

View File

@ -754,6 +754,7 @@ namespace ts {
emitModuleElementDeclarationFlags(node);
write("type ");
writeTextOfNode(currentSourceFile, node.name);
emitTypeParameters(node.typeParameters);
write(" = ");
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError);
write(";");

View File

@ -1786,10 +1786,10 @@ namespace ts {
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
UnionOrIntersection = Union | Intersection,
StructuredType = ObjectType | Union | Intersection,
/* @internal */
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
/* @internal */
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
}
// Properties common to all types

View File

@ -0,0 +1,14 @@
//// [typeAliasDeclarationEmit.ts]
export type callback<T> = () => T;
export type CallbackArray<T extends callback> = () => T;
//// [typeAliasDeclarationEmit.js]
define(["require", "exports"], function (require, exports) {
});
//// [typeAliasDeclarationEmit.d.ts]
export declare type callback<T> = () => T;
export declare type CallbackArray<T extends callback> = () => T;

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/typeAliasDeclarationEmit.ts ===
export type callback<T> = () => T;
>callback : Symbol(callback, Decl(typeAliasDeclarationEmit.ts, 0, 0))
>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 1, 21))
>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 1, 21))
export type CallbackArray<T extends callback> = () => T;
>CallbackArray : Symbol(CallbackArray, Decl(typeAliasDeclarationEmit.ts, 1, 34))
>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 3, 26))
>callback : Symbol(callback, Decl(typeAliasDeclarationEmit.ts, 0, 0))
>T : Symbol(T, Decl(typeAliasDeclarationEmit.ts, 3, 26))

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/typeAliasDeclarationEmit.ts ===
export type callback<T> = () => T;
>callback : () => T
>T : T
>T : T
export type CallbackArray<T extends callback> = () => T;
>CallbackArray : () => T
>T : T
>callback : () => T
>T : T

View File

@ -0,0 +1,7 @@
// @target: ES5
// @module: AMD
// @declaration: true
export type callback<T> = () => T;
export type CallbackArray<T extends callback> = () => T;