Skip to content

Commit

Permalink
fix: babel-plugin-proposal-function-bind: ts-ignore (#14707)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jul 5, 2022
1 parent d68be3f commit f1c4ea3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/babel-plugin-proposal-function-bind/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ export default declare(api => {
return scope.path.setData("functionBind", id);
}

function getObject(bind: t.BindExpression) {
if (t.isExpression(bind.object)) {
return bind.object;
}

return (bind.callee as t.MemberExpression).object;
}

function getStaticContext(bind: t.BindExpression, scope: Scope) {
const object =
bind.object ||
// @ts-ignore Fixme: should check bind.callee type first
bind.callee.object;
const object = getObject(bind);
return (
scope.isStatic(object) &&
(t.isSuper(object) ? t.thisExpression() : object)
Expand All @@ -35,12 +40,10 @@ export default declare(api => {
t.assignmentExpression("=", tempId, bind.object),
bind.callee,
]);
} else {
// @ts-ignore Fixme: should check bind.callee type first
} else if (t.isMemberExpression(bind.callee)) {
bind.callee.object = t.assignmentExpression(
"=",
tempId,
// @ts-ignore Fixme: should check bind.callee type first
bind.callee.object,
);
}
Expand Down

0 comments on commit f1c4ea3

Please sign in to comment.