From 5e4b85ab1cc3cd1c29213e3e26e6caed7c63521a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 1 Dec 2020 10:45:05 -0500 Subject: [PATCH] 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 --- lib/babel-packages.js.flow | 6 ++++++ .../src/{index.js => index.ts} | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) rename packages/babel-helper-get-function-arity/src/{index.js => index.ts} (72%) diff --git a/lib/babel-packages.js.flow b/lib/babel-packages.js.flow index 11c681b051..e500b5fd93 100644 --- a/lib/babel-packages.js.flow +++ b/lib/babel-packages.js.flow @@ -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; +} diff --git a/packages/babel-helper-get-function-arity/src/index.js b/packages/babel-helper-get-function-arity/src/index.ts similarity index 72% rename from packages/babel-helper-get-function-arity/src/index.js rename to packages/babel-helper-get-function-arity/src/index.ts index 6b00da3c35..e4ce063da1 100644 --- a/packages/babel-helper-get-function-arity/src/index.js +++ b/packages/babel-helper-get-function-arity/src/index.ts @@ -1,7 +1,7 @@ import * as t from "@babel/types"; -export default function (node): number { - const params: Array = 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)) {