Skip to content

Additional information about type definitions #22

@jlogar

Description

@jlogar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions