Closed
Description
TypeScript Version: 2.0.6
Code
app.ts
type Foo<T> = {
foo<U>(): Foo<U>
};
function foo() {
return {} as Foo<number>;
}
Expected behavior:
app.d.ts
declare type Foo<T> = {
foo<U>(): Foo<U>;
};
declare function foo(): Foo<number>;
Actual behavior:
declare type Foo<T> = {
foo<U>(): Foo<U>;
};
declare function foo(): {
foo<U>(): Foo;
};
The generated declarations file cannot be referenced by other code because Foo
is missing the generic parameter. Furthermore, hovering over function foo in app.ts shows the return value as the expanded type (i.e. shows the whole body of the declaration).
The workaround is to declare Foo
as an interface or to annotate the return value for function foo.