diff --git a/integration/ng_update_migrations/src/app/migration-tests/base-component.css b/integration/ng_update_migrations/src/app/migration-tests/base-component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/integration/ng_update_migrations/src/app/migration-tests/base-component.ts b/integration/ng_update_migrations/src/app/migration-tests/base-component.ts new file mode 100644 index 0000000000..2a390ee272 --- /dev/null +++ b/integration/ng_update_migrations/src/app/migration-tests/base-component.ts @@ -0,0 +1,24 @@ +import {Component, NgModule} from '@angular/core'; +import {NG_ASYNC_VALIDATORS} from '@angular/forms'; + +export const hostBindings = { + class: 'test-base-comp', +}; + +const nonExportedStyleUrlsVar = ['./base-component.css']; + +@Component({ + selector: 'base-comp', + template: ` + This is the template. + `, + host: hostBindings, + styleUrls: nonExportedStyleUrlsVar, + providers: [ + {provide: NG_ASYNC_VALIDATORS, useValue: null}, + ] +}) +export class BaseComponentFromOtherFile {} + +@NgModule({declarations: [BaseComponentFromOtherFile]}) +export class BaseComponentModule {} diff --git a/integration/ng_update_migrations/src/app/migration-tests/undecorated-base-classes-with-di.ts b/integration/ng_update_migrations/src/app/migration-tests/undecorated-base-classes-with-di.ts new file mode 100644 index 0000000000..446fcc4738 --- /dev/null +++ b/integration/ng_update_migrations/src/app/migration-tests/undecorated-base-classes-with-di.ts @@ -0,0 +1,42 @@ +import {Directive, NgModule, NgZone} from '@angular/core'; + +export class BaseClass1 { + constructor(zone: NgZone) {} +} + +@Directive({selector: 'sel'}) +export class DirectiveWithInheritedCtor extends BaseClass1 {} + +export class BaseClass2 { + constructor(zone: NgZone) {} +} + +@Directive({selector: 'sel'}) +export class DirectiveWithExplicitCtor extends BaseClass2 { + constructor(zone: NgZone) { + super(zone); + } +} + +export class BaseClassWithoutCtor {} + +@Directive({selector: 'sel'}) +export class DirectiveWithoutInheritedCtor extends BaseClassWithoutCtor {} + +export class BaseClass3 { + constructor(zone: NgZone) {} +} +export class PassThroughClass extends BaseClass3 {} + +@Directive({selector: 'sel'}) +export class DirectiveWithInheritedCtorAndClassesInBetween extends PassThroughClass {} + +@NgModule({ + declarations: [ + DirectiveWithInheritedCtor, + DirectiveWithoutInheritedCtor, + DirectiveWithExplicitCtor, + DirectiveWithInheritedCtorAndClassesInBetween, + ] +}) +export class TestModule {} diff --git a/integration/ng_update_migrations/src/app/migration-tests/undecorated-base-classes-with-di_expected.ts b/integration/ng_update_migrations/src/app/migration-tests/undecorated-base-classes-with-di_expected.ts new file mode 100644 index 0000000000..971b8a98b8 --- /dev/null +++ b/integration/ng_update_migrations/src/app/migration-tests/undecorated-base-classes-with-di_expected.ts @@ -0,0 +1,45 @@ +import {Directive, NgModule, NgZone} from '@angular/core'; + +@Directive() +export class BaseClass1 { + constructor(zone: NgZone) {} +} + +@Directive({selector: 'sel'}) +export class DirectiveWithInheritedCtor extends BaseClass1 {} + +export class BaseClass2 { + constructor(zone: NgZone) {} +} + +@Directive({selector: 'sel'}) +export class DirectiveWithExplicitCtor extends BaseClass2 { + constructor(zone: NgZone) { + super(zone); + } +} + +export class BaseClassWithoutCtor {} + +@Directive({selector: 'sel'}) +export class DirectiveWithoutInheritedCtor extends BaseClassWithoutCtor {} + +@Directive() +export class BaseClass3 { + constructor(zone: NgZone) {} +} +@Directive() +export class PassThroughClass extends BaseClass3 {} + +@Directive({selector: 'sel'}) +export class DirectiveWithInheritedCtorAndClassesInBetween extends PassThroughClass {} + +@NgModule({ + declarations: [ + DirectiveWithInheritedCtor, + DirectiveWithoutInheritedCtor, + DirectiveWithExplicitCtor, + DirectiveWithInheritedCtorAndClassesInBetween, + ] +}) +export class TestModule {} diff --git a/integration/ng_update_migrations/src/app/migration-tests/undecorated-derived-classes.ts b/integration/ng_update_migrations/src/app/migration-tests/undecorated-derived-classes.ts new file mode 100644 index 0000000000..f68ab1c697 --- /dev/null +++ b/integration/ng_update_migrations/src/app/migration-tests/undecorated-derived-classes.ts @@ -0,0 +1,31 @@ +import {Directive, NgModule, NgZone} from '@angular/core'; +import {CheckboxControlValueAccessor} from '@angular/forms'; +import {BaseComponentFromOtherFile} from './base-component'; + + +@Directive({ + selector: 'my-base-dir', + providers: [{provide: NgZone, useValue: null}] +}) +export class BaseDirective {} + +export class DerivedDirective extends BaseDirective {} + +export class DerivedDirectiveFromNodeModules extends CheckboxControlValueAccessor {} + +export class DerivedComponentFromOtherSourceFile extends BaseComponentFromOtherFile {} + +@NgModule({ + declarations: [ + DerivedDirective, + DerivedDirectiveFromNodeModules, + DerivedComponentFromOtherSourceFile, + ], +}) +export class TestModule {} + + +@NgModule({ + declarations: [BaseDirective], +}) +export class BaseClassesModule {} diff --git a/integration/ng_update_migrations/src/app/migration-tests/undecorated-derived-classes_expected.ts b/integration/ng_update_migrations/src/app/migration-tests/undecorated-derived-classes_expected.ts new file mode 100644 index 0000000000..3b2042b8ea --- /dev/null +++ b/integration/ng_update_migrations/src/app/migration-tests/undecorated-derived-classes_expected.ts @@ -0,0 +1,62 @@ +import { Directive, NgModule, NgZone, Component } from '@angular/core'; +import { CheckboxControlValueAccessor, NG_VALUE_ACCESSOR, NG_ASYNC_VALIDATORS } from '@angular/forms'; +import { BaseComponentFromOtherFile, hostBindings } from './base-component'; + + +@Directive({ + selector: 'my-base-dir', + providers: [{provide: NgZone, useValue: null}] +}) +export class BaseDirective {} + +@Directive({ + selector: 'my-base-dir', + providers: [{ provide: NgZone, useValue: null }] +}) +export class DerivedDirective extends BaseDirective {} + +@Directive({ + selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]", + host: { + "(change)": "onChange($event.target.checked)", + "(blur)": "onTouched()" + }, + providers: [{ + provide: NG_VALUE_ACCESSOR, + useExisting: CheckboxControlValueAccessor, + multi: true + }] +}) +export class DerivedDirectiveFromNodeModules extends CheckboxControlValueAccessor {} + +@Component({ + selector: 'base-comp', + template: ` + This is the template. + `, + host: hostBindings, + providers: [ + { provide: NG_ASYNC_VALIDATORS, useValue: null }, + ], + // The following fields were copied from the base class, + // but could not be updated automatically to work in the + // new file location. Please add any required imports for + // the properties below: + styleUrls: nonExportedStyleUrlsVar +}) +export class DerivedComponentFromOtherSourceFile extends BaseComponentFromOtherFile {} + +@NgModule({ + declarations: [ + DerivedDirective, + DerivedDirectiveFromNodeModules, + DerivedComponentFromOtherSourceFile, + ], +}) +export class TestModule {} + + +@NgModule({ + declarations: [BaseDirective], +}) +export class BaseClassesModule {}