Skip to content

Commit 3f8a54e

Browse files
committed
refactor: simplify traverse interop to nullish coalescing
1 parent 8d983ef commit 3f8a54e

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

scripts/generate-sdk.mts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ import { getRootPath } from './utils/path-helpers.mts'
2727
import { runCommand } from './utils/run-command.mts'
2828

2929
// CJS/ESM interop: @babel/traverse wraps the function under .default in ESM
30-
const traverse = (
31-
typeof _traverse === 'function'
32-
? _traverse
33-
: (_traverse as unknown as { default: typeof _traverse }).default
34-
) as typeof _traverse
30+
const traverse = ((_traverse as any).default ?? _traverse) as typeof _traverse
3531

3632
const OPENAPI_URL = 'https://api.socket.dev/v0/openapi'
3733

test/unit/bundle-validation.test.mts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import _traverse from '@babel/traverse'
1212
import { describe, expect, it } from 'vitest'
1313

1414
// CJS/ESM interop: @babel/traverse wraps the function under .default in ESM
15-
const traverse = (
16-
typeof _traverse === 'function'
17-
? _traverse
18-
: (_traverse as unknown as { default: typeof _traverse }).default
19-
) as typeof _traverse
15+
const traverse = ((_traverse as any).default ?? _traverse) as typeof _traverse
2016

2117
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2218
const packagePath = path.resolve(__dirname, '../..')

0 commit comments

Comments
 (0)