typescript-generator icon indicating copy to clipboard operation
typescript-generator copied to clipboard

Incompatible property warning if duplicate properties from the unwrapped object

Open YuerLee opened this issue 11 months ago • 0 comments

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: image

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;
}

YuerLee avatar Mar 20 '24 06:03 YuerLee