vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incompatible property warning if duplicate properties from the unwrapped object

YuerLee opened this issue · 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;
}