typescript-generator
typescript-generator copied to clipboard
Incompatible property warning if duplicate properties from the unwrapped object
Hi, I faced a special case in which the result would have an incompatible property.
Here is the thing: we have an interfaceCustomFieldEnabledDto
which has nested object and the property name is the same: { customFields: { customFields: { [index: string]: any } } }
; But sometimes we want to return the value with @JsonUnwrapped
like the UnwrappedDto
: { customFields: { [index: string]: any } }
.
Code snapshot:
In the result, UnwrappedDto
would have a warning from IDE as the 'customFields' is incompatible with theCustomFieldEnabledDto
.
Code: https://replit.com/@YuerLee/typescript-generator-duplicate-name#target/api.ts
///
Not sure that could we detect the duplicate properties and use Omit
to avoid the error? e.g.,
export interface UnwrappedDto extends Omit<CustomFieldEnabledDto, 'customFields'> {
customFields: { [index: string]: any };
id: string;
}