Open balzdur opened 1 year ago
Hi @balzdur and thanks for reporting!
This is indeed an interesting use-case. From glancing over the code it seems the current implementation expected the allOf prop to be used for merging only.
The implementation currently expects complete types and then create an intersection of those, while what you're demonstrating here could be considered more like create a completely new type.
Implementation-wise I'd try to refactor this to first merge the schemas and then create the typescript interface from that.
The output would then probably just look like this for your example
export type Address = {
line1?: string;
line2?: string;
city?: string;
};
export type AddressRequired = {
line1: string;
line2?: string;
city: string;
};
The AST generator seems ignoring
allOf
usage when it comes to merging definition (and not distinct types)My use case is well described in this article and address the need to make some optional properties required.
Using the example from the article :
Generated :
Expected (or something like that):