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

[Feat Request] support inline params name #1

Closed
axetroy opened this issue Apr 5, 2018 · 4 comments
Closed

[Feat Request] support inline params name #1

axetroy opened this issue Apr 5, 2018 · 4 comments
Assignees
Labels
new feature New feature or request
Milestone

Comments

@axetroy
Copy link
Contributor

axetroy commented Apr 5, 2018

This extension is awesome and useful.

Can you consider to add a feature for CallExpression AST node?

before:

function getUserInfo(name: string): void {
  //
}

getUserInfo("username");

after:

function getUserInfo(name: string): void {
  //
}

// "name: " is a decorator, create by extension
getUserInfo(name: "username");
@MartinJohns
Copy link
Owner

Hey @axetroy! I'm glad you like the extension, and I'm surprised someone actually found it. :-)

I can add the feature you want this evening, and I plan to make the different options configurable using the VS Code settings. And there are some gotchas and bugs which I also will tackle soon.

@MartinJohns MartinJohns added this to the 0.2.0 milestone Apr 5, 2018
@MartinJohns MartinJohns added the new feature New feature or request label Apr 5, 2018
@MartinJohns MartinJohns self-assigned this Apr 5, 2018
@MartinJohns
Copy link
Owner

MartinJohns commented Apr 8, 2018

Hey @axetroy,

When testing this new feature I've noticed something and I'd like to hear your opinion on it, as you suggested the feature.

When a variable is passed as the argument that matches the parameters name, should there still be a decoration rendered?

For example:

function someFunc(name: string, age: number, job: string): void { /* ... */ }

const name = 'Bob';
const occupation = 'Builder';
someFunc(name, 40, occupation);

Should this result in a rendered decoration: someFunc(name: name, age: 40, job: occupation);
Or omit the decoraton: someFunc(name, age: 50, job: occupation);

I tend to prefer the omit option, as the repetition serves no purpose.

@MartinJohns
Copy link
Owner

MartinJohns commented Apr 8, 2018

I've opted for the omit version. If you desire the opposite, please just open a new feature request. :-)

I've also released version 0.2.0 which contains this feature.

@axetroy
Copy link
Contributor Author

axetroy commented Apr 8, 2018

@MartinJohns
great!

I would like to enable this feature as default.

If you were used Webstorm, you should found this feature is supported by build-in.

It's clear to known what params you call with this function.

for example:

before:

function createPoint(x: number, y: number) {
  return {
    x,
    y
  };
}

const point = createPoint(0, 1);

after:

1

with this feature, I have clearly known that x = 0, y = 1 and will not mistake them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants