Skip to content

Commit d5da06c

Browse files
committed
fix: dont add an extra null type if one is already included in the union/intersection
1 parent 4224a28 commit d5da06c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/process-schema.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ export function schemaToType(
126126
};
127127
}
128128

129+
// already got a nullable type, no need to add null
130+
if (types.some((t) => t === 'null')) {
131+
return {
132+
name,
133+
hasQuestionToken,
134+
type: intersect
135+
? // @ts-expect-error -> bad type in ts-morph (arguably)
136+
Writers.intersectionType(...types)
137+
: // @ts-expect-error -> bad type in ts-morph (arguably)
138+
Writers.unionType(...types),
139+
};
140+
}
129141
return {
130142
name,
131143
hasQuestionToken,

0 commit comments

Comments
 (0)