Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible property warning if duplicate properties from the unwrapped object #1054

Open
YuerLee opened this issue Mar 20, 2024 · 0 comments

Comments

@YuerLee
Copy link

YuerLee commented Mar 20, 2024

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant