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

Paramters transform: add loose option for default params #5776

Closed
4 tasks
hzoo opened this issue May 26, 2017 · 2 comments
Closed
4 tasks

Paramters transform: add loose option for default params #5776

hzoo opened this issue May 26, 2017 · 2 comments
Labels
area: perf Has PR i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@hzoo
Copy link
Member

hzoo commented May 26, 2017

Ref necolas/react-native-web#490 (comment) cc @necolas

Input

function bar1 (arg1 = 1) {}
bar1.length // 0

Current

function bar2() {
  var arg1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
}
bar2.length // 0

Expected (loose option)

function bar3(arg1) {
  if (arg1 === undefined) {
    arg1 = 1;
  }
  // cannot change Function.protoype.length
}
bar3.length // 1

Change

@peey
Copy link
Contributor

peey commented May 26, 2017

@hzoo I'm planning to add a "ignoreArity" option to #5751 . After it gets merged it's planned to be used by the parameters transform, so this functionality could be easily added there

@maurobringolf
Copy link
Contributor

I started working on this, but its more of a sketch up to now. Feedback appreciated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: perf Has PR i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

5 participants