mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Merge pull request #4202 from Microsoft/fix4194
Fix #4194: emit type paramters in type alias declaration
This commit is contained in:
commit
24aa58ebee
@ -750,14 +750,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeTypeAliasDeclaration(node: TypeAliasDeclaration) {
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
write("type ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
emitTypeParameters(node.typeParameters);
|
||||
write(" = ");
|
||||
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError);
|
||||
write(";");
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
|
||||
function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
|
||||
14
tests/baselines/reference/typeAliasDeclarationEmit.js
Normal file
14
tests/baselines/reference/typeAliasDeclarationEmit.js
Normal 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;
|
||||
13
tests/baselines/reference/typeAliasDeclarationEmit.symbols
Normal file
13
tests/baselines/reference/typeAliasDeclarationEmit.symbols
Normal 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))
|
||||
|
||||
13
tests/baselines/reference/typeAliasDeclarationEmit.types
Normal file
13
tests/baselines/reference/typeAliasDeclarationEmit.types
Normal 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
|
||||
|
||||
13
tests/baselines/reference/typeAliasDeclarationEmit2.js
Normal file
13
tests/baselines/reference/typeAliasDeclarationEmit2.js
Normal 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;
|
||||
};
|
||||
@ -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))
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/typeAliasDeclarationEmit2.ts ===
|
||||
|
||||
export type A<a> = { value: a };
|
||||
>A : { value: a; }
|
||||
>a : a
|
||||
>value : a
|
||||
>a : a
|
||||
|
||||
7
tests/cases/compiler/typeAliasDeclarationEmit.ts
Normal file
7
tests/cases/compiler/typeAliasDeclarationEmit.ts
Normal file
@ -0,0 +1,7 @@
|
||||
// @target: ES5
|
||||
// @module: AMD
|
||||
// @declaration: true
|
||||
|
||||
export type callback<T> = () => T;
|
||||
|
||||
export type CallbackArray<T extends callback> = () => T;
|
||||
5
tests/cases/compiler/typeAliasDeclarationEmit2.ts
Normal file
5
tests/cases/compiler/typeAliasDeclarationEmit2.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @target: ES5
|
||||
// @module: AMD
|
||||
// @declaration: true
|
||||
|
||||
export type A<a> = { value: a };
|
||||
Loading…
x
Reference in New Issue
Block a user