Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named parameters and properties #9007

Closed
yjaaidi opened this issue Jun 7, 2016 · 2 comments
Closed

Named parameters and properties #9007

yjaaidi opened this issue Jun 7, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@yjaaidi
Copy link

yjaaidi commented Jun 7, 2016

Hi!

I'm using TypeScript with named parameters massively like this.

class User {
  public firstName: string;
  public lastName: string;
  constructor({firstName, lastName}: {firstName: string, lastName: string}) {
    this.firstName = firstName;
    this.lastName = lastName;
  }
}

new User({firstName: 'Foo', lastName: 'BAR'});

And I would love to be able to generate the properties automatically like this.

class User {
  constructor({public firstName, public lastName}: {firstName: string, lastName: string}) {}
}

new User({firstName: 'Foo', lastName: 'BAR'});

I think that this feature can be really interesting and would encourage more developers to use named parameters which I think is one of the most important best practices in TypeScript and any other language by the way.

Thank you in advance.

@RyanCavanaugh
Copy link
Member

Duplicate of #5326 ?

@yjaaidi
Copy link
Author

yjaaidi commented Jun 7, 2016

Oups! In fact, couldn't find it, so sorry!

@yjaaidi yjaaidi closed this as completed Jun 7, 2016
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 7, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants