Open
Description
Bug Report
🔎 Search Terms
syntax error declaration emit generics "Cannot find name" ts2304
🕗 Version & Regression Information
- This is syntactically incorrect output from tsc
- It is not a regression
- This is the behavior in every version I tried (3.3 - 4.2.0-dev.20201222)
⏯ Playground Link
Playground link with relevant code
Important: The playground itself has a rendering bug in the display of the declaration. It still looks invalid. But it's invalid in another way in the truthful output. I paste the truthful output below.
💻 Code
// @declaration
type Wrap<A> = {
nest: A
};
interface PreventInliningInDeclarationEmit {
}
export type PublicWrap<X, Y = {}> = Wrap<Y> & PreventInliningInDeclarationEmit;
export function fn<T> (arg: T) : PublicWrap<T> {
return { nest: arg }
}
const nested = fn({ foo: 1}); // Syntax Error in declaration emit here
export default nested;
🙁 Actual behavior
Emitted declaration has syntax error. Cannot find name 'T'. (ts2304)
declare type Wrap<A> = {
nest: A;
};
interface PreventInliningInDeclarationEmit {
}
export declare type PublicWrap<X, Y = {}> = Wrap<Y> & PreventInliningInDeclarationEmit;
export declare function fn<T>(arg: T): PublicWrap<T>;
declare const nested: PublicWrap<T, {}>;
export default nested;
🙂 Expected behavior
A valid declaration.
declare type Wrap<A> = {
nest: A;
};
interface PreventInliningInDeclarationEmit {
}
export declare type PublicWrap<X, Y = {}> = Wrap<Y> & PreventInliningInDeclarationEmit;
export declare function fn<T>(arg: T): PublicWrap<T>;
declare const nested: PublicWrap<{
foo: number;
}>;
export default nested;