openapi-ts
openapi-ts copied to clipboard
Support `moduleResolution: nodenext`
Description
I have a package.json file where moduleResolution is set to nodenext. Thus, import statements require the .js file extension, but the generated code does not include them. Is there a configuration setting that will force the code generator to insert the required .js extension on the imports?
Hey @ballcoach12, not at the moment, but my initial reaction is that this should be trivial to add
@mrlubos, thanks for the quick reply, and I am quite impressed with how you guys are willing to make this package better and better!
@mrlubos I have a created a fix for this, but I wasn't able to get all the tests working, would it be possible for you to help with this? I will open a draft PR today. Thanks :D
+1 to this issue. Would very much love to have the extensions in the imports.
Any progress or updates? We're considering including @hey-api/openapi-ts in a new project, but this is blocking us.
I am running into this issue also too now.
@DanielRivers Did you change your project settings or it's a new project?
This will be available in the next release and it should just work™. If you need to preserve the old behaviour, set output.tsConfigPath to off. If your tsconfig file is located in a nested folder, you can use output.tsConfigPath to point to that file as well. If none of this helps, it's likely because you're using an older configuration – comment here and I'll see what I can do.
Hello, First, thank you for the work you did. hey-api is awesome, really !
In my workflow, I run the createClient function from a provider.generator.ts file with tsx. It seems that hey-api do not to take my tsconfig.json.
Here is a stackblitz to reproduce the issue: https://stackblitz.com/edit/stackblitz-starters-kf85xyx5?file=index.ts
If you check the generated files, imports are appended with .js.
Thank you very much :)
@Wassim24 omitting tsConfigPath in your example or setting it to path.join(__dirname, 'tsconfig.json') works, both will append .js. I might need to look at debugging this better, not sure which path it's resolving to in your example. Even when I changed it to a relative path ./tsconfig.json it didn't work, it might be related to running it through tsx or createClient(). Would need to debug more! Let me know if one of those 2 approaches I shared works for you
Hello @mrlubos,
Using the path.join works correctly, if i have a little time, i could investigate more about the issue.
Thanks !
Don't worry about it, you'd need to run the source. I'll have a look at some point