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

typescript-angular: support angular 9 #5370

Merged
merged 6 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String TAGGED_UNIONS = "taggedUnions";
public static final String NG_VERSION = "ngVersion";
public static final String PROVIDED_IN_ROOT = "providedInRoot";
public static final String MODULE_WITH_PROVIDERS = "moduleWithProviders";
public static final String API_MODULE_PREFIX = "apiModulePrefix";
public static final String SERVICE_SUFFIX = "serviceSuffix";
public static final String SERVICE_FILE_SUFFIX = "serviceFileSuffix";
Expand All @@ -55,7 +56,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";

protected String ngVersion = "8.0.0";
protected String ngVersion = "9.0.0";
protected String npmRepository = null;
private boolean useSingleRequestParameter = false;
protected String serviceSuffix = "Service";
Expand Down Expand Up @@ -123,7 +124,7 @@ public String getName() {

@Override
public String getHelp() {
return "Generates a TypeScript Angular (2.x - 7.x) client library.";
return "Generates a TypeScript Angular (2.x - 9.x) client library.";
}

@Override
Expand Down Expand Up @@ -192,6 +193,12 @@ public void processOpts() {
additionalProperties.put(PROVIDED_IN_ROOT, false);
}

if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put(MODULE_WITH_PROVIDERS, true);
macjohnny marked this conversation as resolved.
Show resolved Hide resolved
} else {
additionalProperties.put(MODULE_WITH_PROVIDERS, false);
}

additionalProperties.put(NG_VERSION, ngVersion);
additionalProperties.put("injectionToken", ngVersion.atLeast("4.0.0") ? "InjectionToken" : "OpaqueToken");
additionalProperties.put("injectionTokenTyped", ngVersion.atLeast("4.0.0"));
Expand Down Expand Up @@ -253,7 +260,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// Set the typescript version compatible to the Angular version
if (ngVersion.atLeast("8.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put("tsVersion", ">=3.6.0 <3.8.0");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("tsVersion", ">=3.4.0 <3.6.0");
} else if (ngVersion.atLeast("7.0.0")) {
additionalProperties.put("tsVersion", ">=3.1.1 <3.2.0");
Expand All @@ -267,7 +276,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// Set the rxJS version compatible to the Angular version
if (ngVersion.atLeast("8.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put("rxjsVersion", "6.5.3");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("rxjsVersion", "6.5.0");
} else if (ngVersion.atLeast("7.0.0")) {
additionalProperties.put("rxjsVersion", "6.3.0");
Expand Down Expand Up @@ -297,7 +308,10 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
additionalProperties.put("useOldNgPackagr", !ngVersion.atLeast("5.0.0"));

// Specific ng-packagr configuration
if (ngVersion.atLeast("8.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put("ngPackagrVersion", "9.0.1");
additionalProperties.put("tsickleVersion", "0.38.0");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("ngPackagrVersion", "5.4.0");
additionalProperties.put("tsickleVersion", "0.35.0");
} else if (ngVersion.atLeast("7.0.0")) {
Expand All @@ -319,6 +333,8 @@ private void addNpmPackageGeneration(SemVer ngVersion) {

// set zone.js version
if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("zonejsVersion", "0.10.2");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("zonejsVersion", "0.9.1");
} else if (ngVersion.atLeast("5.0.0")) {
// compatible versions to Angular 5+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { {{classname}} } from './{{importPath}}';
{{/hasMore}}{{/apis}}{{/apiInfo}} {{/providedInRoot}}]
})
export class {{apiModuleClassName}} {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders{{#moduleWithProviders}}<{{apiModuleClassName}}>{{/moduleWithProviders}}{
return {
ngModule: {{apiModuleClassName}},
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
wwwroot/*.js
node_modules
typings
dist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.0-SNAPSHOT
3.3.2-SNAPSHOT
Loading