fix(common): Update types for TypeScript nullability support
This commit is contained in:
@ -38,8 +38,8 @@ import {Directive, DoCheck, ElementRef, Input, IterableChanges, IterableDiffer,
|
||||
*/
|
||||
@Directive({selector: '[ngClass]'})
|
||||
export class NgClass implements DoCheck {
|
||||
private _iterableDiffer: IterableDiffer<string>;
|
||||
private _keyValueDiffer: KeyValueDiffer<string, any>;
|
||||
private _iterableDiffer: IterableDiffer<string>|null;
|
||||
private _keyValueDiffer: KeyValueDiffer<string, any>|null;
|
||||
private _initialClasses: string[] = [];
|
||||
private _rawClass: string[]|Set<string>|{[klass: string]: any};
|
||||
|
||||
|
@ -73,8 +73,8 @@ export class NgComponentOutlet implements OnChanges, OnDestroy {
|
||||
@Input() ngComponentOutletContent: any[][];
|
||||
@Input() ngComponentOutletNgModuleFactory: NgModuleFactory<any>;
|
||||
|
||||
private _componentRef: ComponentRef<any> = null;
|
||||
private _moduleRef: NgModuleRef<any> = null;
|
||||
private _componentRef: ComponentRef<any>|null = null;
|
||||
private _moduleRef: NgModuleRef<any>|null = null;
|
||||
|
||||
constructor(private _viewContainerRef: ViewContainerRef) {}
|
||||
|
||||
|
@ -114,7 +114,7 @@ export class NgForOf<T> implements DoCheck, OnChanges {
|
||||
|
||||
get ngForTrackBy(): TrackByFunction<T> { return this._trackByFn; }
|
||||
|
||||
private _differ: IterableDiffer<T> = null;
|
||||
private _differ: IterableDiffer<T>|null = null;
|
||||
private _trackByFn: TrackByFunction<T>;
|
||||
|
||||
constructor(
|
||||
@ -159,13 +159,13 @@ export class NgForOf<T> implements DoCheck, OnChanges {
|
||||
(item: IterableChangeRecord<any>, adjustedPreviousIndex: number, currentIndex: number) => {
|
||||
if (item.previousIndex == null) {
|
||||
const view = this._viewContainer.createEmbeddedView(
|
||||
this._template, new NgForOfContext(null, this.ngForOf, null, null), currentIndex);
|
||||
const tuple = new RecordViewTuple(item, view);
|
||||
this._template, new NgForOfContext<T>(null !, this.ngForOf, -1, -1), currentIndex);
|
||||
const tuple = new RecordViewTuple<T>(item, view);
|
||||
insertTuples.push(tuple);
|
||||
} else if (currentIndex == null) {
|
||||
this._viewContainer.remove(adjustedPreviousIndex);
|
||||
} else {
|
||||
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>>>view);
|
||||
insertTuples.push(tuple);
|
||||
|
@ -102,10 +102,10 @@ import {Directive, EmbeddedViewRef, Input, TemplateRef, ViewContainerRef} from '
|
||||
@Directive({selector: '[ngIf]'})
|
||||
export class NgIf {
|
||||
private _context: NgIfContext = new NgIfContext();
|
||||
private _thenTemplateRef: TemplateRef<NgIfContext> = null;
|
||||
private _elseTemplateRef: TemplateRef<NgIfContext> = null;
|
||||
private _thenViewRef: EmbeddedViewRef<NgIfContext> = null;
|
||||
private _elseViewRef: EmbeddedViewRef<NgIfContext> = null;
|
||||
private _thenTemplateRef: TemplateRef<NgIfContext>|null = null;
|
||||
private _elseTemplateRef: TemplateRef<NgIfContext>|null = null;
|
||||
private _thenViewRef: EmbeddedViewRef<NgIfContext>|null = null;
|
||||
private _elseViewRef: EmbeddedViewRef<NgIfContext>|null = null;
|
||||
|
||||
constructor(private _viewContainer: ViewContainerRef, templateRef: TemplateRef<NgIfContext>) {
|
||||
this._thenTemplateRef = templateRef;
|
||||
|
@ -61,7 +61,7 @@ export class NgStyle implements DoCheck {
|
||||
changes.forEachChangedItem((record) => this._setStyle(record.key, record.currentValue));
|
||||
}
|
||||
|
||||
private _setStyle(nameAndUnit: string, value: string|number): void {
|
||||
private _setStyle(nameAndUnit: string, value: string|number|null|undefined): void {
|
||||
const [name, unit] = nameAndUnit.split('.');
|
||||
value = value != null && unit ? `${value}${unit}` : value;
|
||||
|
||||
|
Reference in New Issue
Block a user