From: Nicolo Ribaudo Date: Thu, 23 Feb 2023 16:55:37 +0100 Subject: [PATCH] Update Babel and TS (#15442) origin: backport, https://github.com/babel/babel/commit/b9994d53010b732bed47737cc3ce409ff30f40bf --- package.json | 14 +- packages/babel-generator/src/index.ts | 2 +- .../src/rest.ts | 5 +- packages/babel-traverse/src/path/ancestry.ts | 2 +- packages/babel-types/src/index.ts | 2 +- yarn.lock | 228 +++++++++--------- 6 files changed, 129 insertions(+), 124 deletions(-) --- packages/babel-generator/src/index.ts | 2 +- packages/babel-plugin-transform-parameters/src/rest.ts | 5 ++++- packages/babel-traverse/src/path/ancestry.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/babel-generator/src/index.ts b/packages/babel-generator/src/index.ts index 765c5fb..247dbd7 100644 --- a/packages/babel-generator/src/index.ts +++ b/packages/babel-generator/src/index.ts @@ -95,7 +95,7 @@ function normalizeOptions( } if (format.compact === "auto") { - format.compact = code.length > 500000; // 500KB + format.compact = typeof code === "string" && code.length > 500_000; // 500KB if (format.compact) { console.error( diff --git a/packages/babel-plugin-transform-parameters/src/rest.ts b/packages/babel-plugin-transform-parameters/src/rest.ts index e3d04d7..14950cf 100644 --- a/packages/babel-plugin-transform-parameters/src/rest.ts +++ b/packages/babel-plugin-transform-parameters/src/rest.ts @@ -120,7 +120,10 @@ const memberExpressionOptimisationVisitor: Visitor = { const { parentPath } = path; // Is this identifier the right hand side of a default parameter? - if (parentPath.listKey === "params" && parentPath.key < state.offset) { + if ( + parentPath.listKey === "params" && + (parentPath.key as number) < state.offset + ) { return; } diff --git a/packages/babel-traverse/src/path/ancestry.ts b/packages/babel-traverse/src/path/ancestry.ts index 70cba82..990e83d 100644 --- a/packages/babel-traverse/src/path/ancestry.ts +++ b/packages/babel-traverse/src/path/ancestry.ts @@ -112,7 +112,7 @@ export function getEarliestCommonAncestorFrom( // handle keys const earliestKeyIndex = keys.indexOf(earliest.parentKey); - const currentKeyIndex = keys.indexOf(path.parentKey as string); + const currentKeyIndex = keys.indexOf(path.parentKey); if (earliestKeyIndex > currentKeyIndex) { // key appears before so it's earlier earliest = path;