build(bazel): Turning on strictPropertyInitialization for Angular. (#24572)

All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close #24572
This commit is contained in:
Rado Kirov
2018-06-18 16:38:33 -07:00
committed by Miško Hevery
parent 39c7769c9e
commit c95437f15d
189 changed files with 1273 additions and 632 deletions

View File

@ -18,7 +18,8 @@ import {Component} from '@angular/core';
</div>`
})
export class LowerUpperPipeComponent {
value: string;
// TODO(issue/24571): remove '!'.
value !: string;
change(value: string) { this.value = value; }
}
// #enddocregion

View File

@ -43,7 +43,8 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
`
})
export class MyExpandoCmp {
stateExpression: string;
// TODO(issue/24571): remove '!'.
stateExpression !: string;
constructor() { this.collapse(); }
expand() { this.stateExpression = 'expanded'; }
collapse() { this.stateExpression = 'collapsed'; }

View File

@ -11,7 +11,8 @@ import {Component, ContentChild, Directive, Input} from '@angular/core';
@Directive({selector: 'pane'})
export class Pane {
@Input() id: string;
// TODO(issue/24571): remove '!'.
@Input() id !: string;
}
@Component({
@ -21,7 +22,8 @@ export class Pane {
`
})
export class Tab {
@ContentChild(Pane) pane: Pane;
// TODO(issue/24571): remove '!'.
@ContentChild(Pane) pane !: Pane;
}
@Component({

View File

@ -15,7 +15,8 @@ class ChildDirective {
@Directive({selector: 'someDir'})
class SomeDir implements AfterContentInit {
@ContentChild(ChildDirective) contentChild: ChildDirective;
// TODO(issue/24571): remove '!'.
@ContentChild(ChildDirective) contentChild !: ChildDirective;
ngAfterContentInit() {
// contentChild is set

View File

@ -11,7 +11,8 @@ import {Component, ContentChildren, Directive, Input, QueryList} from '@angular/
@Directive({selector: 'pane'})
export class Pane {
@Input() id: string;
// TODO(issue/24571): remove '!'.
@Input() id !: string;
}
@Component({
@ -22,8 +23,10 @@ export class Pane {
`
})
export class Tab {
@ContentChildren(Pane) topLevelPanes: QueryList<Pane>;
@ContentChildren(Pane, {descendants: true}) arbitraryNestedPanes: QueryList<Pane>;
// TODO(issue/24571): remove '!'.
@ContentChildren(Pane) topLevelPanes !: QueryList<Pane>;
// TODO(issue/24571): remove '!'.
@ContentChildren(Pane, {descendants: true}) arbitraryNestedPanes !: QueryList<Pane>;
get serializedPanes(): string {
return this.topLevelPanes ? this.topLevelPanes.map(p => p.id).join(', ') : '';

View File

@ -15,7 +15,8 @@ class ChildDirective {
@Directive({selector: 'someDir'})
class SomeDir implements AfterContentInit {
@ContentChildren(ChildDirective) contentChildren: QueryList<ChildDirective>;
// TODO(issue/24571): remove '!'.
@ContentChildren(ChildDirective) contentChildren !: QueryList<ChildDirective>;
ngAfterContentInit() {
// contentChildren is set

View File

@ -55,7 +55,9 @@ import {Injectable, InjectionToken, Injector, Optional, ReflectiveInjector} from
describe('ClassProvider', () => {
it('works', () => {
// #docregion ClassProvider
abstract class Shape { name: string; }
abstract class Shape { // TODO(issue/24571): remove '!'.
name !: string;
}
class Square extends Shape {
name = 'square';
@ -92,7 +94,9 @@ import {Injectable, InjectionToken, Injector, Optional, ReflectiveInjector} from
describe('StaticClassProvider', () => {
it('works', () => {
// #docregion StaticClassProvider
abstract class Shape { name: string; }
abstract class Shape { // TODO(issue/24571): remove '!'.
name !: string;
}
class Square extends Shape {
name = 'square';

View File

@ -11,7 +11,8 @@ import {Component, Directive, Input, ViewChild} from '@angular/core';
@Directive({selector: 'pane'})
export class Pane {
@Input() id: string;
// TODO(issue/24571): remove '!'.
@Input() id !: string;
}
@Component({

View File

@ -15,7 +15,8 @@ class ChildDirective {
@Component({selector: 'someCmp', templateUrl: 'someCmp.html'})
class SomeCmp implements AfterViewInit {
@ViewChild(ChildDirective) child: ChildDirective;
// TODO(issue/24571): remove '!'.
@ViewChild(ChildDirective) child !: ChildDirective;
ngAfterViewInit() {
// child is set

View File

@ -11,7 +11,8 @@ import {AfterViewInit, Component, Directive, Input, QueryList, ViewChildren} fro
@Directive({selector: 'pane'})
export class Pane {
@Input() id: string;
// TODO(issue/24571): remove '!'.
@Input() id !: string;
}
@Component({
@ -27,7 +28,8 @@ export class Pane {
`,
})
export class ViewChildrenComp implements AfterViewInit {
@ViewChildren(Pane) panes: QueryList<Pane>;
// TODO(issue/24571): remove '!'.
@ViewChildren(Pane) panes !: QueryList<Pane>;
serializedPanes: string = '';
shouldShow = false;

View File

@ -15,7 +15,8 @@ class ChildDirective {
@Component({selector: 'someCmp', templateUrl: 'someCmp.html'})
class SomeCmp implements AfterViewInit {
@ViewChildren(ChildDirective) viewChildren: QueryList<ChildDirective>;
// TODO(issue/24571): remove '!'.
@ViewChildren(ChildDirective) viewChildren !: QueryList<ChildDirective>;
ngAfterViewInit() {
// viewChildren is set

View File

@ -106,8 +106,9 @@ import {TestBed} from '@angular/core/testing';
// #docregion OnChanges
@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements OnChanges {
// TODO(issue/24571): remove '!'.
@Input()
prop: number;
prop !: number;
ngOnChanges(changes: SimpleChanges) {
// changes.prop contains the old and the new value...

View File

@ -30,7 +30,8 @@ interface Hero {
<button (click)="addHero.emit()">Add Hero</button>`,
})
class Ng2HeroesComponent {
@Input() heroes: Hero[];
// TODO(issue/24571): remove '!'.
@Input() heroes !: Hero[];
@Output() addHero = new EventEmitter();
@Output() removeHero = new EventEmitter();
}
@ -69,8 +70,10 @@ class Ng1HeroComponentWrapper extends UpgradeComponent implements OnInit, OnChan
OnDestroy {
// The names of the input and output properties here must match the names of the
// `<` and `&` bindings in the AngularJS component that is being wrapped
@Input() hero: Hero;
@Output() onRemove: EventEmitter<void>;
// TODO(issue/24571): remove '!'.
@Input() hero !: Hero;
// TODO(issue/24571): remove '!'.
@Output() onRemove !: EventEmitter<void>;
constructor(@Inject(ElementRef) elementRef: ElementRef, @Inject(Injector) injector: Injector) {
// We must pass the name of the directive as used by AngularJS to the super
super('ng1Hero', elementRef, injector);