Migrate Babel from Flow to TypeScript (except Babel parser) (#11578)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ export default declare((api, options) => {
|
||||
|
||||
function pushAssign(objId, prop, body) {
|
||||
if (prop.kind === "get" && prop.kind === "set") {
|
||||
pushMutatorDefine(objId, prop, body);
|
||||
pushMutatorDefine(objId, prop);
|
||||
} else {
|
||||
body.push(
|
||||
t.expressionStatement(
|
||||
@@ -43,6 +43,7 @@ export default declare((api, options) => {
|
||||
prop.key,
|
||||
prop.computed || t.isLiteral(prop.key),
|
||||
),
|
||||
// @ts-expect-error todo(flow->ts): double-check type error
|
||||
getValue(prop),
|
||||
),
|
||||
),
|
||||
@@ -65,12 +66,12 @@ export default declare((api, options) => {
|
||||
}
|
||||
|
||||
body.push(
|
||||
...buildMutatorMapAssign({
|
||||
...(buildMutatorMapAssign({
|
||||
MUTATOR_MAP_REF: getMutatorId(),
|
||||
KEY: t.cloneNode(key),
|
||||
VALUE: getValue(prop),
|
||||
KIND: t.identifier(prop.kind),
|
||||
}),
|
||||
}) as t.Statement[]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ export default declare((api, options) => {
|
||||
exit(path, state) {
|
||||
const { node, parent, scope } = path;
|
||||
let hasComputed = false;
|
||||
for (const prop of (node.properties: Array<Object>)) {
|
||||
for (const prop of node.properties) {
|
||||
hasComputed = prop.computed === true;
|
||||
if (hasComputed) break;
|
||||
}
|
||||
@@ -194,6 +195,7 @@ export default declare((api, options) => {
|
||||
);
|
||||
}
|
||||
|
||||
// @ts-expect-error todo(flow->ts) `void` should not be used as variable
|
||||
if (single) {
|
||||
path.replaceWith(single);
|
||||
} else {
|
||||
Reference in New Issue
Block a user