-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts files
Milestone
Description
π Search Terms
return type of generic function
Well, actually I am not sure what keyword could be searched by...
π Version & Regression Information
This problem only occurs since version v5.5.2~v5.5.3, not ever in v5.4.5 or even before
β― Playground Link
π» Code
function create<T extends {}>(): T {
return null as any;
}
export const c = create<{
data: {
['a_b_c']: string; // missing in typeof c
['sss']: string; // missing in typeof c
s_d: string;
queryData?: string;
};
['a_b_c']: string; // but this is ok
}>();
export interface IData {
['a_b_c']: string; // ok
nested: {
['d_e_f']: string; // ok
value: string;
};
}π Actual behavior
The type of c doesn't contain data.a_b_c and data.sss properties, whatever in editor or generated .d.ts declaration file
π Expected behavior
The return type of function create should exactly match the generic type parameter T
Additional information about the issue
It seems only nested and name-quoted properties would disappear.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts files