refactor: fix undecorated classes with angular features in repo (#36921)

A few instances of undecorated classes with Angular features
have been discovered in the framework repo. This commit fixes
those.

PR Close #36921
This commit is contained in:
Paul Gschwendtner 2020-05-05 16:47:14 +02:00 committed by Alex Rickabaugh
parent 0577bf0e3e
commit e17fe90aaa
6 changed files with 15 additions and 8 deletions

View File

@ -3,6 +3,7 @@ import {
AfterContentInit, AfterContentInit,
AfterViewChecked, AfterViewChecked,
AfterViewInit, AfterViewInit,
Directive,
DoCheck, DoCheck,
OnChanges, OnChanges,
OnDestroy, OnDestroy,
@ -15,7 +16,8 @@ import { LoggerService } from './logger.service';
let nextId = 1; let nextId = 1;
// #docregion ngOnInit // #docregion ngOnInit
export class PeekABoo implements OnInit { @Directive()
export class PeekABooDirective implements OnInit {
constructor(private logger: LoggerService) { } constructor(private logger: LoggerService) { }
// implement OnInit's `ngOnInit` method // implement OnInit's `ngOnInit` method
@ -34,7 +36,7 @@ export class PeekABoo implements OnInit {
}) })
// Don't HAVE to mention the Lifecycle Hook interfaces // Don't HAVE to mention the Lifecycle Hook interfaces
// unless we want typing and tool support. // unless we want typing and tool support.
export class PeekABooComponent extends PeekABoo implements export class PeekABooComponent extends PeekABooDirective implements
OnChanges, OnInit, DoCheck, OnChanges, OnInit, DoCheck,
AfterContentInit, AfterContentChecked, AfterContentInit, AfterContentChecked,
AfterViewInit, AfterViewChecked, AfterViewInit, AfterViewChecked,

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {OnDestroy, OnInit} from '@angular/core'; import {Directive, OnDestroy, OnInit} from '@angular/core';
import {FormGroup} from '../model'; import {FormGroup} from '../model';
@ -23,6 +23,7 @@ import {AsyncValidatorFn, ValidatorFn} from './validators';
* *
* @publicApi * @publicApi
*/ */
@Directive()
export class AbstractFormGroupDirective extends ControlContainer implements OnInit, OnDestroy { export class AbstractFormGroupDirective extends ControlContainer implements OnInit, OnDestroy {
/** /**
* @description * @description

View File

@ -7,8 +7,8 @@
*/ */
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Compiler, Injector, isDevMode, NgModuleFactoryLoader, NgModuleRef, NgZone, Type, ɵConsole as Console} from '@angular/core'; import {Compiler, Injectable, Injector, isDevMode, NgModuleFactoryLoader, NgModuleRef, NgZone, Type, ɵConsole as Console} from '@angular/core';
import {BehaviorSubject, defer, EMPTY, Observable, of, Subject, Subscription} from 'rxjs'; import {BehaviorSubject, EMPTY, Observable, of, Subject, Subscription} from 'rxjs';
import {catchError, filter, finalize, map, switchMap, tap} from 'rxjs/operators'; import {catchError, filter, finalize, map, switchMap, tap} from 'rxjs/operators';
import {QueryParamsHandling, Route, Routes, standardizeConfig, validateConfig} from './config'; import {QueryParamsHandling, Route, Routes, standardizeConfig, validateConfig} from './config';
@ -288,6 +288,7 @@ function defaultRouterHook(snapshot: RouterStateSnapshot, runExtras: {
* *
* @publicApi * @publicApi
*/ */
@Injectable()
export class Router { export class Router {
private currentUrlTree: UrlTree; private currentUrlTree: UrlTree;
private rawUrlTree: UrlTree; private rawUrlTree: UrlTree;

View File

@ -7,12 +7,13 @@
*/ */
import {ViewportScroller} from '@angular/common'; import {ViewportScroller} from '@angular/common';
import {OnDestroy} from '@angular/core'; import {Injectable, OnDestroy} from '@angular/core';
import {Unsubscribable} from 'rxjs'; import {Unsubscribable} from 'rxjs';
import {NavigationEnd, NavigationStart, Scroll} from './events'; import {NavigationEnd, NavigationStart, Scroll} from './events';
import {Router} from './router'; import {Router} from './router';
@Injectable()
export class RouterScroller implements OnDestroy { export class RouterScroller implements OnDestroy {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
private routerEventsSubscription!: Unsubscribable; private routerEventsSubscription!: Unsubscribable;

View File

@ -135,6 +135,7 @@ export class UpgradeNg1ComponentAdapterBuilder {
} }
} }
@Directive()
class UpgradeNg1ComponentAdapter implements OnInit, OnChanges, DoCheck { class UpgradeNg1ComponentAdapter implements OnInit, OnChanges, DoCheck {
private controllerInstance: IControllerInstance|null = null; private controllerInstance: IControllerInstance|null = null;
destinationObj: IBindingDestination|null = null; destinationObj: IBindingDestination|null = null;

View File

@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, SimpleChanges, ɵlooseIdentical as looseIdentical} from '@angular/core'; import {Directive, DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, SimpleChanges, ɵlooseIdentical as looseIdentical} from '@angular/core';
import {IAttributes, IAugmentedJQuery, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../../src/common/src/angular1'; import {IAttributes, IAugmentedJQuery, IDirective, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../../src/common/src/angular1';
import {$SCOPE} from '../../src/common/src/constants'; import {$SCOPE} from '../../src/common/src/constants';
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../../src/common/src/upgrade_helper'; import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../../src/common/src/upgrade_helper';
import {isFunction} from '../../src/common/src/util'; import {isFunction} from '../../src/common/src/util';
@ -66,6 +66,7 @@ class Bindings {
* *
* @publicApi * @publicApi
*/ */
@Directive()
export class UpgradeComponent implements OnInit, OnChanges, DoCheck, OnDestroy { export class UpgradeComponent implements OnInit, OnChanges, DoCheck, OnDestroy {
private helper: UpgradeHelper; private helper: UpgradeHelper;