convert @babel/helper-member-expression-to-functions to ts (#12925)
This commit is contained in:
parent
beb7cf8b24
commit
d1f3d30598
@ -16,5 +16,8 @@
|
||||
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||
"dependencies": {
|
||||
"@babel/types": "workspace:^7.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/traverse": "workspace:^7.12.17"
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import * as t from "@babel/types";
|
||||
import { willPathCastToBoolean } from "./util";
|
||||
|
||||
class AssignmentMemoiser {
|
||||
private _map: WeakMap<object, any>;
|
||||
constructor() {
|
||||
this._map = new WeakMap();
|
||||
}
|
||||
@ -84,7 +85,8 @@ const handle = {
|
||||
// noop.
|
||||
},
|
||||
|
||||
handle(member: t.NodePath<t.Expression>, noDocumentAll: boolean) {
|
||||
// todo(flow->ts) member:NodePath<t.Expression>, refactor function body to avoid too many typecasts
|
||||
handle(member: any, noDocumentAll: boolean) {
|
||||
const { node, parent, parentPath, scope } = member;
|
||||
|
||||
if (member.isOptionalMemberExpression()) {
|
||||
@ -350,7 +352,12 @@ const handle = {
|
||||
const ref = scope.generateUidIdentifierBasedOnNode(node);
|
||||
scope.push({ id: ref });
|
||||
|
||||
value.left = t.assignmentExpression("=", t.cloneNode(ref), value.left);
|
||||
value.left = t.assignmentExpression(
|
||||
"=",
|
||||
t.cloneNode(ref),
|
||||
// @ts-expect-error todo(flow->ts) value.left is possibly PrivateName, which is not usable here
|
||||
value.left,
|
||||
);
|
||||
|
||||
parentPath.replaceWith(
|
||||
t.sequenceExpression([this.set(member, value), t.cloneNode(ref)]),
|
||||
@ -1,3 +1,5 @@
|
||||
import type { NodePath } from "@babel/traverse";
|
||||
|
||||
/**
|
||||
* Test if a NodePath will be cast to boolean when evaluated.
|
||||
*
|
||||
@ -621,6 +621,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@babel/helper-member-expression-to-functions@workspace:packages/babel-helper-member-expression-to-functions"
|
||||
dependencies:
|
||||
"@babel/traverse": "workspace:^7.12.17"
|
||||
"@babel/types": "workspace:^7.13.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user