Skip to content

Commit 2380ada

Browse files
author
nicosammito
committed
feat: update getValueFromType to handle null samples and add test for LIST type generation
1 parent e85cc8d commit 2380ada

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/extraction/getValueFromType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ export const getValueFromType = (
7474
if (checker.isArrayType(t)) {
7575
const typeRef = t as ts.TypeReference;
7676
const elementType = typeRef.typeArguments?.[0] || checker.getAnyType();
77-
return [generateSample(elementType, node, visited)];
77+
const sample = generateSample(elementType, node, visited);
78+
return sample === "null" ? [generateSample(elementType, node, visited)] : [];
7879
}
7980

8081
// 4. Handle Objects / Interfaces

test/valueFromType.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('getValueFromType', () => {
3434
const result = getValueFromType('LIST<LIST<NUMBER>>', DATA_TYPES);
3535
expect(result.value).toEqual([[0]]);
3636
});
37+
38+
it('sollte LIST Typen generieren', () => {
39+
const result = getValueFromType('LIST<unknown>', DATA_TYPES);
40+
expect(result.value).toEqual([]);
41+
});
3742
});
3843

3944
describe('Unions & Literals', () => {

0 commit comments

Comments
 (0)