* refactor: move @babel/helper-get-function-arity to ts * Review comments * chore: add flow interface
13 lines
310 B
TypeScript
13 lines
310 B
TypeScript
import * as t from "@babel/types";
|
|
|
|
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)) {
|
|
return i;
|
|
}
|
|
}
|
|
return params.length;
|
|
}
|