diff --git a/packages/babel-traverse/src/path/family.ts b/packages/babel-traverse/src/path/family.ts index 0e38ec28a751..6b49758ba489 100644 --- a/packages/babel-traverse/src/path/family.ts +++ b/packages/babel-traverse/src/path/family.ts @@ -231,29 +231,25 @@ function _getCompletionRecords( path.isLabeledStatement() ) { // @ts-expect-error(flow->ts): todo - records = addCompletionRecords(path.get("body"), records, context); + return addCompletionRecords(path.get("body"), records, context); } else if (path.isProgram() || path.isBlockStatement()) { - records.push( - // @ts-expect-error(flow->ts): todo - ...getStatementListCompletion(path.get("body"), context), - ); + // @ts-expect-error(flow->ts): todo + return getStatementListCompletion(path.get("body"), context); } else if (path.isFunction()) { return _getCompletionRecords(path.get("body"), context); } else if (path.isTryStatement()) { records = addCompletionRecords(path.get("block"), records, context); records = addCompletionRecords(path.get("handler"), records, context); } else if (path.isCatchClause()) { - records = addCompletionRecords(path.get("body"), records, context); + return addCompletionRecords(path.get("body"), records, context); } else if (path.isSwitchStatement()) { - records = completionRecordForSwitch(path.get("cases"), records, context); + return completionRecordForSwitch(path.get("cases"), records, context); } else if (path.isSwitchCase()) { - records.push( - ...getStatementListCompletion(path.get("consequent"), { - canHaveBreak: true, - shouldPopulateBreak: false, - inCaseClause: true, - }), - ); + return getStatementListCompletion(path.get("consequent"), { + canHaveBreak: true, + shouldPopulateBreak: false, + inCaseClause: true, + }); } else if (path.isBreakStatement()) { records.push(BreakCompletion(path)); } else { diff --git a/packages/babel-types/src/modifications/flow/removeTypeDuplicates.ts b/packages/babel-types/src/modifications/flow/removeTypeDuplicates.ts index 90d8ba233a17..b57d62e0eec1 100644 --- a/packages/babel-types/src/modifications/flow/removeTypeDuplicates.ts +++ b/packages/babel-types/src/modifications/flow/removeTypeDuplicates.ts @@ -17,7 +17,8 @@ function getQualifiedName(node: t.GenericTypeAnnotation["id"]) { * Dedupe type annotations. */ export default function removeTypeDuplicates( - nodes: (t.FlowType | false | null | undefined)[], + // todo(babel-8): change type to Array<...> + nodes: ReadonlyArray, ): t.FlowType[] { const generics = {}; const bases = {}; @@ -48,7 +49,8 @@ export default function removeTypeDuplicates( if (isUnionTypeAnnotation(node)) { if (typeGroups.indexOf(node.types) < 0) { - nodes.push(...node.types); + // todo(babel-8): remove type casting + (nodes as any).push(...node.types); typeGroups.push(node.types); } continue;