refactor: move @babel/helper-get-function-arity to ts (#12414)

* refactor: move @babel/helper-get-function-arity to ts

* Review comments

* chore: add flow interface
This commit is contained in:
Huáng Jùnliàng 2020-12-01 10:45:05 -05:00 committed by GitHub
parent 3266d2679a
commit 5e4b85ab1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -43,3 +43,9 @@ declare module "@babel/helper-optimise-call-expression" {
optional: boolean
): BabelNodeCallExpression | BabelNodeOptionalCallExpression;
}
declare module "@babel/helper-get-function-arity" {
declare export default function helperGetFunctionArity(
node: BabelNodeFunction
): number;
}

View File

@ -1,7 +1,7 @@
import * as t from "@babel/types";
export default function (node): number {
const params: Array<Object> = node.params;
export default function (node: t.Function): number {
const params = node.params;
for (let i = 0; i < params.length; i++) {
const param = params[i];
if (t.isAssignmentPattern(param) || t.isRestElement(param)) {