Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
fedeci committed Aug 11, 2021
1 parent be8a9b8 commit 5d843ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
24 changes: 10 additions & 14 deletions packages/babel-traverse/src/path/family.ts
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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 | false | null | undefined>,
): t.FlowType[] {
const generics = {};
const bases = {};
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5d843ff

Please sign in to comment.