cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

[feature] add "type" keyword in export/import to prevent re-exportation error with TS IsolatedModules option #325

Closed Adrii77 closed 1 month ago

Adrii77 commented 3 months ago

Enable typescript's isolatedModules option causes a re-exportation error from model.ts generated file.

Capture d’écran 2024-07-17 à 14 46 38

Is it possible to add the typescript "type"'s keyword for import and export ?

I saw Angular CLI will enable isolatedModules option by default for new projects.

I'm using Angular 18.1

luisfpg commented 1 month ago

You can just adjust the modelIndex.handlebars template. I'm not sure if this would always be failproof or depends on the model. Enums by default are generated as classes, but you can set in options "enumStyle": "alias" to generate as an union type with string values. In that case it would really be type-only. So, given the very short time I'm having for this project, I'd recommend editing the template and setting the enumStyle if you need this.