Skip to content

Commit 42d1afc

Browse files
committed
fix(test): resolve TypeScript errors in bundle validation
Adds @types/babel__traverse to fix type checking errors in CI. Uses type assertions to work around version mismatches between @babel/types used by parser (7.26.3) vs traverse types (7.28.4).
1 parent 961f05a commit 42d1afc

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@eslint/js": "9.35.0",
6464
"@socketregistry/packageurl-js": "1.3.5",
6565
"@socketsecurity/lib": "3.1.3",
66+
"@types/babel__traverse": "7.28.0",
6667
"@types/node": "24.9.2",
6768
"@typescript/native-preview": "7.0.0-dev.20250926.1",
6869
"@vitest/coverage-v8": "4.0.3",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/bundle-validation.test.mts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ async function checkBundledDependencies(content: string): Promise<{
6161
const bundledDeps: string[] = []
6262

6363
// Parse the bundle into an AST.
64-
const ast = parse(content, {
64+
const file = parse(content, {
6565
sourceType: 'module',
6666
plugins: ['typescript'],
6767
})
6868

6969
// Collect all import sources from the AST.
7070
const importSources = new Set<string>()
71-
// @ts-expect-error - traverse types are complex
72-
traverse(ast, {
73-
ImportDeclaration(path) {
71+
72+
traverse(file as any, {
73+
ImportDeclaration(path: any) {
7474
const source = path.node.source.value
7575
importSources.add(source)
7676
},
@@ -97,15 +97,16 @@ async function checkBundledDependencies(content: string): Promise<{
9797
// If it's just in string literals (like constants), that's fine.
9898
// Use AST to check if it appears in any meaningful way.
9999
let foundInCode = false
100-
// @ts-expect-error - traverse types are complex
101-
traverse(ast, {
102-
StringLiteral(path) {
100+
101+
traverse(file as any, {
102+
StringLiteral(path: any) {
103103
// Skip string literals - these are fine
104104
if (pattern.test(path.node.value)) {
105105
// It's in a string literal, which is fine
106106
}
107107
},
108-
Identifier(path) {
108+
109+
Identifier(path: any) {
109110
// Check if the package name appears in identifiers or other code
110111
if (
111112
pattern.test(path.node.name) ||

0 commit comments

Comments
 (0)