Skip to content

Binding element alias is kept in function expressions even though they are never used in declaration files.Β #56992

Closed
@dragomirtitian

Description

@dragomirtitian

πŸ”Ž Search Terms

binding element alias declaration files

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ

⏯ Playground Link

Playground Link

πŸ’» Code

export const fn1 = ({ prop:b }: { prop: number }) => { };

export const fn2 = ({ prop:b }: { prop: number }) => b;

export const fn3 = ({ prop:b }: { prop: number }): typeof b => 0;

πŸ™ Actual behavior

b is kept in all exported function signatures, even though it is never used. Even if we have typeof b in the signature of the original function expression, the type printer will remove that and use the resolved type.

export declare const fn1: ({ prop: b }: {
    prop: number;
}) => void;
export declare const fn2: ({ prop: b }: {
    prop: number;
}) => number;
export declare const fn3: ({ prop: b }: {
    prop: number;
}) => number;

πŸ™‚ Expected behavior

b is removed from all signatures since it will never be used. Even if the original type uses typeof the resulting type will resolve any typeof expressions

Additional information about the issue

Related to #55654

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions