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

Templatized ModuleWithProviders in typescript-angular #730

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { {{classname}} } from './{{importPath}}';
{{/hasMore}}{{/apis}}{{/apiInfo}} ]
})
export class ApiModule {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> {
Copy link

@jose-hernandez-001 jose-hernandez-001 Nov 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for consistency with V2 and to allow backwards compatibility with versions of Angular <10 this should be:

public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders{{#genericModuleWithProviders}}<ApiModule>{{/genericModuleWithProviders}} {

To enable the change during code generation you would need to add a property to the Maven build:

<configuration>
    <language>typescript-angular</language>
    <additionalProperties>
        <additionalProperty>ngVersion=10.2.0</additionalProperty>
        <additionalProperty>genericModuleWithProviders=true</additionalProperty>
    </additionalProperties>
</configuration>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback!
I actually copied the method from swagger-api/swagger-codegen#10464 which automatically sets genericModuleWithProviders if angular is >= 7.

return {
ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
Expand Down