ModuleWithProviders without a generic type is deprecated since Angular 9 and mandatory since Angular 10:
See: https://github.com/angular/angular/commit/20cc3ab37e2d79761993dfcec2cafd6393b4f414
3.0.21
Using the generated code (without npm) in an Angular 10 project leads to a TypeScript error and the application not compiling.
Change ModuleWithProviders to ModuleWithProviders<ApiModule> to: https://github.com/swagger-api/swagger-codegen/blob/e6d69ab23a8ad4de1c57bea18a11c386bdd81022/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache#L21.
Edit:
Looks like the option to add a generic type was added in Angular 6.1.0, so my solution breaks earlier versions.
https://github.com/angular/angular/commit/60aeee7abfcc149d9f33ed9519b242b4bccea641#diff-968ca8dead1eca4223cb534b9f0b9c02R79
Hey,
do we really need to support Angular < 6.1.x? Your solution seems to work, so push it please.
I have the same Problem with Angular 10 and swagger-codegen.
The typescript-angular generator maintenance could be better. There are only samples up to Angular 6. Version 7 was released almost 2 years ago. There is a fork of this project called OpenAPI Generator which has samples up to Angular 9. I'm using it with Angular 10 and it is working great.
Same problem here, just migrated to Angular 10 and found that we have to change the auto-generated code to make it work :-(
Edit: I have tried the OpenAPITools generator 5.0 0-beta2 and it looks like working, still have to make further tests but the code generated compiles in Angular 10.
As a workaround, I am running the following command after generating the typescript-angular client:
sed -i 's/ModuleWithProviders {/ModuleWithProviders<ApiModule> {/' <path_to_generated_folder>/api.module.ts
This is the same approach as a workaround for https://github.com/swagger-api/swagger-codegen/issues/8836
Most helpful comment
Hey,
do we really need to support Angular < 6.1.x? Your solution seems to work, so push it please.
I have the same Problem with Angular 10 and swagger-codegen.