fix api build issues

This commit is contained in:
2025-12-25 13:40:38 +01:00
parent 722a185dd9
commit 3ceb837e15
32 changed files with 150 additions and 133 deletions

View File

@@ -241,12 +241,15 @@ describe('API Contract Validation', () => {
const dtoContent = await fs.readFile(dtoPath, 'utf-8');
if (propSchema.nullable) {
// Nullable properties should be optional in TypeScript
const propRegex = new RegExp(`${propName}\\??:\\s*([\\w\\[\\]<>|]+)\\s*;`);
// Nullable properties should be optional OR include `| null` in the type.
const propRegex = new RegExp(`${propName}(\\?)?:\\s*([^;]+);`);
const match = dtoContent.match(propRegex);
if (match) {
// Should include null in the type or be optional
expect(match[1]).toContain('| null');
const optionalMark = match[1];
const typeText = match[2] ?? '';
expect(optionalMark === '?' || typeText.includes('| null')).toBe(true);
}
}
}