babel/packages/babel-plugin-transform-parameters
Benoît Zugmeyer 85ddc297c2 Fix rest parameters indexing with TypeScript 'this parameter' (#9714)
* Fix rest parameters indexing with TypeScript 'this parameter'

The TypeScript [this parameter][0] is a fake parameter and should not be
taken into account when counting the function parameters.  This patch
skips it by using the condition taken from the `transform-typescript`
plugin.

Note: since the `transform-typescript` plugin is removing this kind of
parameter, including it before the `transform-parameters` plugin solves
the issue.  This patch fixes the issue in other cases.

[0]: https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters

* nit: improve the 'this parameter' detection condition

* improve performance by checking the parameter list length before
accessing it
* simplify the test a bit by using the `isIdentifier` second
parameter
2020-01-17 21:00:37 +01:00
..
2020-01-13 22:36:19 +01:00

@babel/plugin-transform-parameters

Compile ES2015 default and rest parameters to ES5

See our website @babel/plugin-transform-parameters for more information.

Install

Using npm:

npm install --save-dev @babel/plugin-transform-parameters

or using yarn:

yarn add @babel/plugin-transform-parameters --dev