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

[FEATURE] Add an option to add extension to relative imports #2189

Open
2 tasks done
edorgeville opened this issue Feb 20, 2025 · 1 comment
Open
2 tasks done

[FEATURE] Add an option to add extension to relative imports #2189

edorgeville opened this issue Feb 20, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@edorgeville
Copy link

edorgeville commented Feb 20, 2025

Why do we need this improvement?

Currently, generated Typescript files using the following command:

asyncapi generate models typescript ./asyncapi.yml -o ./src/models

results in imports looking like this:

import SomeSchema from './SomeSchema';

Unfortunately, this won't compile in ESM projects were tsconfig.json contains "moduleResolution": "nodenext" or "moduleResolution": "node16".

Screenshots

Image

How could it be implemented/designed?

Adding a --tsRelativeImportExtension=<undefined | js | ts> flag (inspired by Typescript's --rewriteRelativeImportExtensions flag and AsyncAPI's CLI --ts* flags), would allow users to override the default behavior with the appropriate extension. .ts and .js should be supported for flexibility.

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR! Given that this could be a cross-repository change (both modelina & asyncapi/cli ), I might need some additional guidance 😅

@edorgeville edorgeville added the enhancement New feature or request label Feb 20, 2025
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant