-
Notifications
You must be signed in to change notification settings - Fork 248
Description
I have feature request about which I'd like your opinion.
In our project we have many AngularJS based grids. The initialization options that set he fields go something like this:
$scope.dtos: SomeGeneratedDtoInterface[];
gb.setColumnDefs([
{field: 'orderType', displayName: translate('ORDER_TYPE'), cellFilter: "translate"},
{field: 'itemType', displayName: translate('ITEM_TYPE')},
{field: 'issueOrderComments', displayName: translate('COMMENTS')}
]);
We would very much like to improve upon this by using TypeScript and the DTO interfaces as generated by this project. The problem is that the fields as defined above are just strings that map to actual fields in the strongly typed DTOs. Ideally we would be able to reference by using some lambda expression like:
field: dtoType => dtoType.orderType
That is not possible with current Typescript version (probably never will be).
The solution that we were thinking about is just adding some static classes that represent the generated DTO types. So we would get:
field: DtoType.orderTypeFieldName
Where the orderTypeFieldName
is a const string containing the field name. So these static classes that I mention would be like type descriptors. And pretty much type safe.
I propose that we add the option to generate the above described classes. An optional extension of course.
We'd be prepared to make a PR if you think something like that would be OK for the project. Let me know and we'll prepare a more detailed proposition. Or if you have a better solution ofcourse :)