Skip to content

Generic return type of function is missing of nested name-quoted propertiesΒ #59107

@fenying

Description

@fenying

πŸ”Ž 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

https://www.typescriptlang.org/play/?ts=5.5.2#code/GYVwdgxgLglg9mABBATgUwIZTQHgCqJoAe2YAJgM6IDeAvgHwAUAlAFyIHUCwAUL4gMTooIFEjAgANpMQYqGMAE8A3L1q9exAA5wUUZAgr6IiALzJ0WXNx6DEZLBnY3+dwQG0A5BgD6AIx8ITwBddiMUGDAAc2VEAHo4xABbGAoKSKjESMQoRS00OGBkVzdELzSKELCoCOjYhOTU9OispFz8wuLbUsQKHzJq2piStwBHEDQURQARRwB+QYzVboFaZbsvXwCg0N6apfjEvxB9KAALVKyqOABrNSZmZc0iHT1W7BRgDAg0RABJWZQDA0DQrMrefyBKp7Ib1RK3UF2MBoIxoAYgvhgjaeMg+NA+YDQ8IHBoIzE9RAANwwkgmizqIzWal4QA

πŸ’» 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 TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts files

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions