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

Add ability to use record types instead of index signatures #706

Closed
wants to merge 1 commit into from

Conversation

crummy
Copy link

@crummy crummy commented Aug 22, 2021

My team uses Record<string, number> syntax instead of { [index: string]: number } syntax. Here is a PR to allow use of this syntax instead. Not very experienced in this codebase so I'm open to feedback and changes.

@vojtechhabarta
Copy link
Owner

Your approach would work but technically Record<string, number> is not indexed type formatted differently, it is generic type for which there is already GenericBasicType.

So more correct solution is to transform IndexedArrayType to GenericBasicType in ModelCompiler. You can create method in ModelCompiler where you can reuse transformBeanPropertyTypes method and call it after transformOptionalProperties.

Another solution is to create an Extension and do the transformation there. The extension could be merged to typescript-generator if you think it would be interesting for others as well.

@vojtechhabarta
Copy link
Owner

Feature released in v2.36.1070 (different implementation).
In Maven use <mapMap>asRecord</mapMap> parameter.

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

Successfully merging this pull request may close these issues.

2 participants