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

move @babel/helper-optimise-call-expression to ts #12411

Merged
merged 2 commits into from Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/babel-packages.js.flow
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;
}
@@ -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>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Does TS check that the JSDoc comment types are correct, when using type annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The JSDoc is checked only when TypeScript is checking JavaScript files: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html

optional: boolean,
): CallExpression | OptionalCallExpression {
if (
Expand Down