build: reformat repo to new clang@1.4.0 (#36613)

PR Close #36613
This commit is contained in:
Joey Perrott
2020-04-13 16:40:21 -07:00
committed by atscott
parent 5e80e7e216
commit 698b0288be
1160 changed files with 31667 additions and 24000 deletions

View File

@ -7,7 +7,7 @@
*/
import {Directive, DoCheck, ElementRef, Input, IterableChanges, IterableDiffer, IterableDiffers, KeyValueChanges, KeyValueDiffer, KeyValueDiffers, Renderer2, ɵisListLikeIterable as isListLikeIterable, ɵstringify as stringify} from '@angular/core';
type NgClassSupportedTypes = string[] | Set<string>| {[klass: string]: any} | null | undefined;
type NgClassSupportedTypes = string[]|Set<string>|{[klass: string]: any}|null|undefined;
/**
* @ngModule CommonModule
@ -83,7 +83,7 @@ export class NgClass implements DoCheck {
this._applyIterableChanges(iterableChanges);
}
} else if (this._keyValueDiffer) {
const keyValueChanges = this._keyValueDiffer.diff(this._rawClass as{[k: string]: any});
const keyValueChanges = this._keyValueDiffer.diff(this._rawClass as {[k: string]: any});
if (keyValueChanges) {
this._applyKeyValueChanges(keyValueChanges);
}
@ -105,8 +105,8 @@ export class NgClass implements DoCheck {
if (typeof record.item === 'string') {
this._toggleClass(record.item, true);
} else {
throw new Error(
`NgClass can only toggle CSS classes expressed as strings, got ${stringify(record.item)}`);
throw new Error(`NgClass can only toggle CSS classes expressed as strings, got ${
stringify(record.item)}`);
}
});

View File

@ -67,13 +67,13 @@ import {ComponentFactoryResolver, ComponentRef, Directive, Injector, Input, NgMo
@Directive({selector: '[ngComponentOutlet]'})
export class NgComponentOutlet implements OnChanges, OnDestroy {
// TODO(issue/24571): remove '!'.
@Input() ngComponentOutlet !: Type<any>;
@Input() ngComponentOutlet!: Type<any>;
// TODO(issue/24571): remove '!'.
@Input() ngComponentOutletInjector !: Injector;
@Input() ngComponentOutletInjector!: Injector;
// TODO(issue/24571): remove '!'.
@Input() ngComponentOutletContent !: any[][];
@Input() ngComponentOutletContent!: any[][];
// TODO(issue/24571): remove '!'.
@Input() ngComponentOutletNgModuleFactory !: NgModuleFactory<any>;
@Input() ngComponentOutletNgModuleFactory!: NgModuleFactory<any>;
private _componentRef: ComponentRef<any>|null = null;
private _moduleRef: NgModuleRef<any>|null = null;

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Directive, DoCheck, EmbeddedViewRef, Input, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDiffers, NgIterable, TemplateRef, TrackByFunction, ViewContainerRef, isDevMode} from '@angular/core';
import {Directive, DoCheck, EmbeddedViewRef, Input, isDevMode, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDiffers, NgIterable, TemplateRef, TrackByFunction, ViewContainerRef} from '@angular/core';
/**
* @publicApi
@ -14,13 +14,21 @@ import {Directive, DoCheck, EmbeddedViewRef, Input, IterableChangeRecord, Iterab
export class NgForOfContext<T, U extends NgIterable<T> = NgIterable<T>> {
constructor(public $implicit: T, public ngForOf: U, public index: number, public count: number) {}
get first(): boolean { return this.index === 0; }
get first(): boolean {
return this.index === 0;
}
get last(): boolean { return this.index === this.count - 1; }
get last(): boolean {
return this.index === this.count - 1;
}
get even(): boolean { return this.index % 2 === 0; }
get even(): boolean {
return this.index % 2 === 0;
}
get odd(): boolean { return !this.even; }
get odd(): boolean {
return !this.even;
}
}
/**
@ -162,13 +170,15 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
this._trackByFn = fn;
}
get ngForTrackBy(): TrackByFunction<T> { return this._trackByFn; }
get ngForTrackBy(): TrackByFunction<T> {
return this._trackByFn;
}
private _ngForOf: U|undefined|null = null;
private _ngForOfDirty: boolean = true;
private _differ: IterableDiffer<T>|null = null;
// TODO(issue/24571): remove '!'.
private _trackByFn !: TrackByFunction<T>;
private _trackByFn!: TrackByFunction<T>;
constructor(
private _viewContainer: ViewContainerRef,
@ -200,8 +210,8 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
try {
this._differ = this._differs.find(value).create(this.ngForTrackBy);
} catch {
throw new Error(
`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
throw new Error(`Cannot find a differ supporting object '${value}' of type '${
getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
}
}
}
@ -214,14 +224,14 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
private _applyChanges(changes: IterableChanges<T>) {
const insertTuples: RecordViewTuple<T, U>[] = [];
changes.forEachOperation(
(item: IterableChangeRecord<any>, adjustedPreviousIndex: number | null,
currentIndex: number | null) => {
(item: IterableChangeRecord<any>, adjustedPreviousIndex: number|null,
currentIndex: number|null) => {
if (item.previousIndex == null) {
// NgForOf is never "null" or "undefined" here because the differ detected
// that a new item needs to be inserted from the iterable. This implies that
// there is an iterable value for "_ngForOf".
const view = this._viewContainer.createEmbeddedView(
this._template, new NgForOfContext<T, U>(null !, this._ngForOf !, -1, -1),
this._template, new NgForOfContext<T, U>(null!, this._ngForOf!, -1, -1),
currentIndex === null ? undefined : currentIndex);
const tuple = new RecordViewTuple<T, U>(item, view);
insertTuples.push(tuple);
@ -229,7 +239,7 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
this._viewContainer.remove(
adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
} else if (adjustedPreviousIndex !== null) {
const view = this._viewContainer.get(adjustedPreviousIndex) !;
const view = this._viewContainer.get(adjustedPreviousIndex)!;
this._viewContainer.move(view, currentIndex);
const tuple = new RecordViewTuple(item, <EmbeddedViewRef<NgForOfContext<T, U>>>view);
insertTuples.push(tuple);
@ -244,7 +254,7 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
const viewRef = <EmbeddedViewRef<NgForOfContext<T, U>>>this._viewContainer.get(i);
viewRef.context.index = i;
viewRef.context.count = ilen;
viewRef.context.ngForOf = this._ngForOf !;
viewRef.context.ngForOf = this._ngForOf!;
}
changes.forEachIdentityChange((record: any) => {

View File

@ -241,11 +241,11 @@ export class NgIf<T = unknown> {
* @publicApi
*/
export class NgIfContext<T = unknown> {
public $implicit: T = null !;
public ngIf: T = null !;
public $implicit: T = null!;
public ngIf: T = null!;
}
function assertTemplate(property: string, templateRef: TemplateRef<any>| null): void {
function assertTemplate(property: string, templateRef: TemplateRef<any>|null): void {
const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
if (!isTemplateRefOrNull) {
throw new Error(`${property} must be a TemplateRef, but received '${stringify(templateRef)}'.`);

View File

@ -8,7 +8,7 @@
import {Attribute, Directive, Host, Input, TemplateRef, ViewContainerRef} from '@angular/core';
import {NgLocalization, getPluralCategory} from '../i18n/localization';
import {getPluralCategory, NgLocalization} from '../i18n/localization';
import {SwitchView} from './ng_switch';
@ -47,9 +47,9 @@ import {SwitchView} from './ng_switch';
@Directive({selector: '[ngPlural]'})
export class NgPlural {
// TODO(issue/24571): remove '!'.
private _switchValue !: number;
private _switchValue!: number;
// TODO(issue/24571): remove '!'.
private _activeView !: SwitchView;
private _activeView!: SwitchView;
private _caseViews: {[k: string]: SwitchView} = {};
constructor(private _localization: NgLocalization) {}
@ -60,7 +60,9 @@ export class NgPlural {
this._updateView();
}
addCase(value: string, switchView: SwitchView): void { this._caseViews[value] = switchView; }
addCase(value: string, switchView: SwitchView): void {
this._caseViews[value] = switchView;
}
private _updateView(): void {
this._clearViews();

View File

@ -62,7 +62,7 @@ export class NgStyle implements DoCheck {
ngDoCheck() {
if (this._differ) {
const changes = this._differ.diff(this._ngStyle !);
const changes = this._differ.diff(this._ngStyle!);
if (changes) {
this._applyChanges(changes);
}

View File

@ -104,7 +104,7 @@ export class SwitchView {
@Directive({selector: '[ngSwitch]'})
export class NgSwitch {
// TODO(issue/24571): remove '!'.
private _defaultViews !: SwitchView[];
private _defaultViews!: SwitchView[];
private _defaultUsed = false;
private _caseCount = 0;
private _lastCaseCheckIndex = 0;
@ -120,7 +120,9 @@ export class NgSwitch {
}
/** @internal */
_addCase(): number { return this._caseCount++; }
_addCase(): number {
return this._caseCount++;
}
/** @internal */
_addDefault(view: SwitchView) {
@ -193,8 +195,7 @@ export class NgSwitchCase implements DoCheck {
/**
* Stores the HTML template to be selected on match.
*/
@Input()
ngSwitchCase: any;
@Input() ngSwitchCase: any;
constructor(
viewContainer: ViewContainerRef, templateRef: TemplateRef<Object>,
@ -206,7 +207,9 @@ export class NgSwitchCase implements DoCheck {
/**
* Performs case matching. For internal use only.
*/
ngDoCheck() { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); }
ngDoCheck() {
this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase));
}
}
/**

View File

@ -101,7 +101,7 @@ export class NgTemplateOutlet implements OnChanges {
private _updateExistingContext(ctx: Object): void {
for (let propName of Object.keys(ctx)) {
(<any>this._viewRef !.context)[propName] = (<any>this.ngTemplateOutletContext)[propName];
(<any>this._viewRef!.context)[propName] = (<any>this.ngTemplateOutletContext)[propName];
}
}
}