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

feat: add option to generate named exports from Typescript generator #622

Merged
merged 10 commits into from
Mar 22, 2022
Merged

feat: add option to generate named exports from Typescript generator #622

merged 10 commits into from
Mar 22, 2022

Conversation

gabormagyar
Copy link
Contributor

@gabormagyar gabormagyar commented Feb 8, 2022

This probably needs tests, I'm not sure when I will have time to add them. Feel free to take over if someone wants to.

It also needs (minor) documentation changes about the added generator option.
Correction: TypeScriptRenderCompleteModelOptions is wholly undocumented if I'm not mistaken, should probably be added at some point

@gabormagyar gabormagyar changed the title feat: Add option to generate named exports from Typescript generator feat: add option to generate named exports from Typescript generator Feb 8, 2022
Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

Yes, we definitely need some tests, examples, and documentation to ensure this works as intended before it can be merged.

It seems you might have auto-formatting enabled in your development environment making unnecessary changes that make it harder to review, do you mind disabling it and re-commit the intended changes? 🙂

You can try to reach out on slack to see if you can find someone to help you finish it 🙂

@gabormagyar
Copy link
Contributor Author

Auto formatting removed

@gabormagyar
Copy link
Contributor Author

gabormagyar commented Feb 25, 2022

@jonaslagoni Please advise if you think there's anything else that needs to be done. I personlally think this doesn't need a separate example.

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good tbh 👍

We do need to update the documentation though: https://github.com/asyncapi/modelina/blob/master/docs/languages/TypeScript.md#rendering-complete-models-to-a-specific-module-system

What's the reason you think an example is unnecessary? 🙂

@coveralls
Copy link

coveralls commented Feb 25, 2022

Pull Request Test Coverage Report for Build 1999047854

  • 25 of 28 (89.29%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.08%) to 92.895%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/generators/typescript/presets/ExportKeywordPreset.ts 4 7 57.14%
Totals Coverage Status
Change from base Build 1958303721: -0.08%
Covered Lines: 2594
Relevant Lines: 2665

💛 - Coveralls

@gabormagyar
Copy link
Contributor Author

@jonaslagoni Added a note to the TypeScript docs.

I don't think this is a big enough thing to add separate examples for. If we add examples for every combination of every possible option it will be a lot of examples. What do you think?

@gabormagyar
Copy link
Contributor Author

Also interestingly the named exports don't really play nice with the generated description comments from the other PR (#621). It still generates valid code, it just looks ugly: the comments are between the export keyword and the node.

I think it's fine for now, but in a future PR I will fix it so that the export keyword is generated through the preset system with priority over any comments. I think this will work but I'm open to suggestions, this is a rather tricky interaction.

@gabormagyar
Copy link
Contributor Author

It might not be as fine as I thought. These comments are not compiled into the *.d.ts files unfortunately, which defeats their purpose for my use case.

For reference, this is what these look like:

export /**
 * ...
 */
type name = ...

@gabormagyar
Copy link
Contributor Author

Fixed, it's not pretty but it works and I do believe it's robust

@gabormagyar gabormagyar requested a review from jonaslagoni March 3, 2022 10:50
Copy link
Collaborator

@Samridhi-98 Samridhi-98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix all the linting errors🙂

src/generators/typescript/TypeScriptGenerator.ts Outdated Show resolved Hide resolved
@gabormagyar gabormagyar requested a review from Samridhi-98 March 3, 2022 20:57
@gabormagyar gabormagyar requested a review from jonaslagoni March 7, 2022 10:48
@gabormagyar
Copy link
Contributor Author

@jonaslagoni What are next steps for this PR?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@gabormagyar gabormagyar requested a review from jonaslagoni March 17, 2022 14:18
Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Samridhi-98 anything you want to add?

Copy link
Collaborator

@Samridhi-98 Samridhi-98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉🎉

@Samridhi-98
Copy link
Collaborator

/rtm

@asyncapi-bot asyncapi-bot merged commit f288773 into asyncapi:master Mar 22, 2022
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.53.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 1.0.0-next.23 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants