Skip to content

Argument destructuring idea #10079

Closed
Closed
@johnfn

Description

@johnfn

If in TypeScript your function takes a dictionary of parameters, I often end up writing code like this:

public doStuff({ arg1, arg2, arg3, arg4 }: { arg1: string, arg2: number, arg3: number, arg4?: boolean })

which is not particularly DRY.

My suggestion would be to write the above code like this:

public doStuff({ arg1: string, arg2: number, arg3: number, arg4?: boolean })

I think this would make a lot of code easier to read. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Out of ScopeThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions