Subject: ABP Proxy Generator Overrides Custom Tags Type Declaration
Environment:
- ABP Suite with custom Customer entity
- C# Backend: .NET with ABP framework
- Angular Frontend: Connected via proxy generation
- Command:
abp generate-proxy -t ng -m connect --url https://localhost:44348 --target connect
Issue Description:
I have a Tags field in the Customer entity that needs to store an array of strings. Since ABP Suite's JSON configuration does not support List types directly, I defined it as a string in the customer.json metadata file.
To override this limitation, I added a property override in both Customer.Extended.cs and CustomerDto.Extended.cs:
public new List<string>? Tags { get; set; } = new List<string>();
This approach worked correctly in AspZero. However, when running the ABP proxy generation command, the TypeScript interfaces are regenerated with conflicting type declarations:
Generated Code (customer.dto.ts):
// Base class defines tags as string | null
export interface CustomerDtoBase {
tags?: string | null;
}
// Extended class attempts to override as string[]
export interface CustomerDto extends CustomerDtoBase {
tags?: string[];
}
This creates a TypeScript compilation error:
TS2430: Interface 'CustomerDto' incorrectly extends interface 'CustomerDtoBase'.
Types of property 'tags' are incompatible.
Type 'string[]' is not assignable to type 'string'.
Current Workaround (Not Sustainable):
I've temporarily fixed this by using Omit to remove the conflicting property:
export interface CustomerDto extends Omit<CustomerDtoBase, 'tags'> {
tags?: string[];
}
However, this workaround is lost every time the proxy is regenerated.
Expected Solution:
The ABP proxy generator should respect C# property overrides and generate TypeScript interfaces that correctly reflect the actual data contract (array of strings), rather than reverting to the base JSON metadata definition.
Alternatively, a configuration option to exclude specific fields from the JSON metadata or to preserve manual overrides would resolve this issue.
Question:
What is the recommended approach to permanently resolve type mismatches between JSON entity metadata and C# property overrides within the ABP proxy generation workflow?
1 Answer(s)
-
0
Hello,
Thank you for the detailed explanation of the issue. It appears that the problem has been resolved on the backend side.
From what I understand, the backend defines
tagsas a single string in the Suite description, but then overrides it in C# as a list of strings. Because of this inconsistency, the proxy generator correctly reports the mismatch, and TypeScript raises an error.To resolve the issue, the backend contract needs to be consistent. You can either keep
tagsas a string everywhere, or model it as a list/array of strings throughout the system. If a serialized string is required for storage purposes, it should be exposed as a separate property with a different name that is not part of the public DTO.Once the backend contract is clean and consistent, the generated Angular proxies should also work correctly.
You can let us know if you need further assistance. Thank you for your cooperation.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)