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

Support verbatimModuleSyntax in TypeScript Generator #1793

Closed
moritzkalwa opened this issue Feb 12, 2024 · 7 comments · Fixed by #1800 · May be fixed by #1873
Closed

Support verbatimModuleSyntax in TypeScript Generator #1793

moritzkalwa opened this issue Feb 12, 2024 · 7 comments · Fixed by #1800 · May be fixed by #1873

Comments

@moritzkalwa
Copy link
Contributor

Reason/Context

Currently the typescript generator does not explicitly export/import interfaces as types. This is an issue when the typescript option 'verbatimModuleSyntax' is enabled and can potentially cause some other pitfalls.

Description

Add a new flag (or make this the default behaviour when using interfaces, afaik that should not cause any issues) that changes the behaviour of 'src/generators/typescript/TypeScriptDependencyManager.ts' so it imports and exports interfaces as types.

Before:

import { PublicUser } from './PublicUser'
interface NewStatePayload {
  members: PublicUser[]
}
export { NewStatePayload }

After:

import type { PublicUser } from './PublicUser'
interface NewStatePayload {
  members: PublicUser[]
}
export type { NewStatePayload }
@moritzkalwa moritzkalwa added the enhancement New feature or request label Feb 12, 2024
Copy link
Contributor

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@jonaslagoni
Copy link
Member

I think it makes sense to just render it by default for interfaces (is there any other cases?) if it has no side effects of course ✌️

All we need is to adapt the dependency manager: https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptDependencyManager.ts#L48

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 4.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jonaslagoni
Copy link
Member

@moritzkalwa not sure if you saw, but I unfortunately had to revert your PR because of breaking changes to the dependency functions and the bug it introduced. I am planning on fixing it at some point, but right now I have to spend time on something else.

If you got the time to help I would really appreciate it 🤙

@moritzkalwa
Copy link
Contributor Author

@moritzkalwa not sure if you saw, but I unfortunately had to revert your PR because of breaking changes to the dependency functions and the bug it introduced. I am planning on fixing it at some point, but right now I have to spend time on something else.

If you got the time to help I would really appreciate it 🤙

I saw and I'm planning on taking another look at it in the future. Haven't had the time to do so yet though, and probably won't until next week. Would love to fix that issue and get this done though, if that is early enough!

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Jun 27, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment