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

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

Support verbatimModuleSyntax in TypeScript Generator #1793

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

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
Sponsor 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
Sponsor 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!

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