Skip to content

Commit

Permalink
move @babel/helper-optimise-call-expression to ts (babel#12411)
Browse files Browse the repository at this point in the history
* move @babel/helper-optimise-call-expression to ts

* chore: add flow interface
  • Loading branch information
JLHwung authored and nicolo-ribaudo committed Dec 2, 2020
1 parent f4cf168 commit a26f4ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions lib/babel-packages.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ declare module "@babel/template" {
program: Program,
};
}

declare module "@babel/helper-optimise-call-expression" {
declare export default function optimiseCallExpression(
callee: BabelNodeExpression,
thisNode: BabelNodeExpression,
args: $Readonly<Array<BabelNodeExpression | BabelNodeSpreadElement>>,
optional: boolean
): BabelNodeCallExpression | BabelNodeOptionalCallExpression;
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import * as t from "@babel/types";
import type {
CallExpression,
Expression,
OptionalCallExpression,
SpreadElement,
} from "@babel/types";

/**
* A helper function that generates a new call expression with given thisNode.
It will also optimize `(...arguments)` to `.apply(arguments)`
*
* @export
* @param {Node} callee The callee of call expression
* @param {Node} thisNode The desired this of call expression
* @param {Node[]} args The arguments of call expression
* @param {Expression} callee The callee of call expression
* @param {Expression} thisNode The desired this of call expression
* @param {Readonly<Array<Expression | SpreadElement>>} args The arguments of call expression
* @param {boolean} optional Whether the call expression is optional
* @returns {CallExpression | OptionalCallExpression} The generated new call expression
*/
export default function (
callee: Node,
thisNode: Node,
args: Node[],
export default function optimiseCallExpression(
callee: Expression,
thisNode: Expression,
args: Readonly<Array<Expression | SpreadElement>>,
optional: boolean,
): CallExpression | OptionalCallExpression {
if (
Expand Down

0 comments on commit a26f4ef

Please sign in to comment.