Skip to content

Commit c7a2f71

Browse files
ericyangpanclaude
andcommitted
fix(tests): resolve TypeScript errors in validation tests
- Cast unknown schemas to object when calling ajv.addSchema() - Add non-null assertion for array access after length check - Add type assertion for regex captured groups - Add null coalescing for optional regex capture 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 8308630 commit c7a2f71

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

tests/validate/manifests.schema.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function loadBaseSchemas(ajv: ReturnType<typeof createAjv>, schemasDir: string)
7777
continue
7878
}
7979
const schema = readJsonFile(schemaPath)
80-
ajv.addSchema(schema, name)
80+
ajv.addSchema(schema as object, name)
8181
}
8282
}
8383

@@ -99,7 +99,7 @@ function resolveRelativeRefs(obj: unknown, baseDir: string, ajv: ReturnType<type
9999
const refSchema = readJsonFile(refPath)
100100
const refId = path.basename(refPath)
101101
if (!ajv.getSchema(refId)) {
102-
ajv.addSchema(refSchema, refId)
102+
ajv.addSchema(refSchema as object, refId)
103103
}
104104
record.$ref = refId
105105
}

tests/validate/translations.structure.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,17 @@ function validateTranslationStructures(rootDir: string): string[] {
131131
structures.set(locale, getLocaleStructure(translationsDir, locale))
132132
}
133133

134-
const referenceLocale = locales[0]
134+
const referenceLocale = locales[0]!
135135
const reference = structures.get(referenceLocale)
136136
if (!reference) return failures
137137

138138
for (let i = 1; i < locales.length; i++) {
139-
const locale = locales[i]
139+
const locale = locales[i]!
140140
const current = structures.get(locale)
141-
if (!current) continue
141+
if (!current) {
142+
failures.push(`[${locale}] structure not found`)
143+
continue
144+
}
142145

143146
const fileDiff = diffSets(new Set(reference.fileList), new Set(current.fileList))
144147
if (fileDiff.onlyInA.length > 0 || fileDiff.onlyInB.length > 0) {

tests/validate/typesAlignment.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ function parseTypeScriptInterface(
8888
const trimmed = line.trim()
8989
const fieldMatch = trimmed.match(/^(\w+)(\?)?\s*:\s*(.+)$/)
9090
if (fieldMatch) {
91-
const name = fieldMatch[1]
91+
const name = fieldMatch[1] as string
9292
const optional = fieldMatch[2] === '?'
93-
const type = fieldMatch[3].trim()
93+
const type = fieldMatch[3]?.trim() ?? 'unknown'
9494
fields[name] = { optional, type }
9595
}
9696
}

0 commit comments

Comments
 (0)