Skip to content

Commit

Permalink
fix: fix perperty initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Apr 19, 2020
1 parent 4ba2f49 commit d3a6438
Show file tree
Hide file tree
Showing 212 changed files with 994 additions and 1,002 deletions.
13 changes: 7 additions & 6 deletions components/affix/affix.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,20 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy {
static ngAcceptInputType_nzOffsetTop: NumberInput;
static ngAcceptInputType_nzOffsetBottom: NumberInput;

@ViewChild('fixedEl', { static: true }) private fixedEl: ElementRef<HTMLDivElement>;
@ViewChild('fixedEl', { static: true }) private fixedEl!: ElementRef<HTMLDivElement>;

@Input() nzTarget: string | Element | Window;
// TODO@hsuanxyz SSR breaks (perhaps)?
@Input() nzTarget: string | Element | Window = window;

@Input()
@WithConfig<number | null>(NZ_CONFIG_COMPONENT_NAME, null)
@WithConfig<number | null>(NZ_CONFIG_COMPONENT_NAME)
@InputNumber()
nzOffsetTop: null | number;
nzOffsetTop: null | number = null;

@Input()
@WithConfig<number | null>(NZ_CONFIG_COMPONENT_NAME, null)
@WithConfig<number | null>(NZ_CONFIG_COMPONENT_NAME)
@InputNumber()
nzOffsetBottom: null | number;
nzOffsetBottom: null | number = null;

@Output() readonly nzChange = new EventEmitter<boolean>();

Expand Down
4 changes: 2 additions & 2 deletions components/alert/alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class NzAlertComponent implements OnChanges, OnDestroy {
@Input() nzMessage: string | TemplateRef<void> | null = null;
@Input() nzDescription: string | TemplateRef<void> | null = null;
@Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info';
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzCloseable: boolean;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzShowIcon: boolean;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputBoolean() nzCloseable: boolean = false;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputBoolean() nzShowIcon: boolean = false;
@Input() @InputBoolean() nzBanner = false;
@Output() readonly nzOnClose = new EventEmitter<boolean>();
closed = false;
Expand Down
6 changes: 3 additions & 3 deletions components/anchor/anchor-link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class NzAnchorLinkComponent implements OnInit, OnDestroy {
@Input() nzHref = '#';

titleStr: string | null = '';
titleTpl: TemplateRef<NzSafeAny>;
titleTpl?: TemplateRef<NzSafeAny>;

@Input()
set nzTitle(value: string | TemplateRef<void>) {
Expand All @@ -53,8 +53,8 @@ export class NzAnchorLinkComponent implements OnInit, OnDestroy {
}
}

@ContentChild('nzTemplate', { static: false }) nzTemplate: TemplateRef<void>;
@ViewChild('linkTitle') linkTitle: ElementRef<HTMLAnchorElement>;
@ContentChild('nzTemplate', { static: false }) nzTemplate!: TemplateRef<void>;
@ViewChild('linkTitle') linkTitle!: ElementRef<HTMLAnchorElement>;

constructor(
public elementRef: ElementRef,
Expand Down
18 changes: 9 additions & 9 deletions components/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,35 @@ export class NzAnchorComponent implements OnDestroy, AfterViewInit, OnChanges {
static ngAcceptInputType_nzBounds: NumberInput;
static ngAcceptInputType_nzOffsetTop: NumberInput;

@ViewChild('ink', { static: false }) private ink: ElementRef;
@ViewChild('ink', { static: false }) private ink!: ElementRef;

@Input() @InputBoolean() nzAffix = true;

@Input()
@WithConfig(NZ_CONFIG_COMPONENT_NAME, false)
@WithConfig(NZ_CONFIG_COMPONENT_NAME)
@InputBoolean()
nzShowInkInFixed: boolean;
nzShowInkInFixed: boolean = false;

@Input()
@WithConfig(NZ_CONFIG_COMPONENT_NAME, 5)
@WithConfig(NZ_CONFIG_COMPONENT_NAME)
@InputNumber()
nzBounds: number;
nzBounds: number = 5;

@Input()
@InputNumber()
@WithConfig<number>(NZ_CONFIG_COMPONENT_NAME)
nzOffsetTop: number;
nzOffsetTop?: number = undefined;

@Input() nzContainer: string | HTMLElement;
@Input() nzTarget: string | HTMLElement;
@Input() nzContainer?: string | HTMLElement;
@Input() nzTarget: string | HTMLElement = '';

@Output() readonly nzClick = new EventEmitter<string>();
@Output() readonly nzScroll = new EventEmitter<NzAnchorLinkComponent>();

visible = false;
wrapperStyle: NgStyleInterface = { 'max-height': '100vh' };

container: HTMLElement | Window;
container?: HTMLElement | Window;

private links: NzAnchorLinkComponent[] = [];
private animating = false;
Expand Down
18 changes: 9 additions & 9 deletions components/auto-complete/autocomplete-trigger.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function getNzAutocompleteMissingPanelError(): Error {
})
export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnDestroy {
/** Bind nzAutocomplete component */
@Input() nzAutocomplete: NzAutocompleteComponent;
@Input() nzAutocomplete!: NzAutocompleteComponent;

onChange: OnChangeType = () => {};
onTouched: OnTouchedType = () => {};
Expand All @@ -82,14 +82,14 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
}
}

private overlayRef: OverlayRef | null;
private portal: TemplatePortal<{}> | null;
private positionStrategy: FlexibleConnectedPositionStrategy;
private previousValue: string | number | null;
private selectionChangeSubscription: Subscription;
private optionsChangeSubscription: Subscription;
private overlayBackdropClickSubscription: Subscription;
private overlayPositionChangeSubscription: Subscription;
private overlayRef: OverlayRef | null = null;
private portal: TemplatePortal<{}> | null = null;
private positionStrategy!: FlexibleConnectedPositionStrategy;
private previousValue: string | number | null = null;
private selectionChangeSubscription!: Subscription;
private optionsChangeSubscription!: Subscription;
private overlayBackdropClickSubscription!: Subscription;
private overlayPositionChangeSubscription!: Subscription;

constructor(
private elementRef: ElementRef,
Expand Down
16 changes: 8 additions & 8 deletions components/auto-complete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ export class NzAutocompleteComponent implements AfterContentInit, AfterViewInit,
static ngAcceptInputType_nzDefaultActiveFirstOption: BooleanInput;
static ngAcceptInputType_nzBackfill: BooleanInput;

@Input() nzWidth: number;
@Input() nzWidth?: number;
@Input() nzOverlayClassName = '';
@Input() nzOverlayStyle: { [key: string]: string } = {};
@Input() @InputBoolean() nzDefaultActiveFirstOption = true;
@Input() @InputBoolean() nzBackfill = false;
@Input() compareWith: CompareWith = (o1, o2) => o1 === o2;
@Input() nzDataSource: AutocompleteDataSource;
@Input() nzDataSource?: AutocompleteDataSource;
@Output()
readonly selectionChange: EventEmitter<NzAutocompleteOptionComponent> = new EventEmitter<NzAutocompleteOptionComponent>();

showPanel: boolean = true;
isOpen: boolean = false;
activeItem: NzAutocompleteOptionComponent;
activeItem?: NzAutocompleteOptionComponent;
dropDownPosition: NzDropDownPosition = 'bottom';

/**
Expand All @@ -110,14 +110,14 @@ export class NzAutocompleteComponent implements AfterContentInit, AfterViewInit,

/** Provided by content */
@ContentChildren(NzAutocompleteOptionComponent, { descendants: true })
fromContentOptions: QueryList<NzAutocompleteOptionComponent>;
fromContentOptions!: QueryList<NzAutocompleteOptionComponent>;
/** Provided by dataSource */
@ViewChildren(NzAutocompleteOptionComponent) fromDataSourceOptions: QueryList<NzAutocompleteOptionComponent>;
@ViewChildren(NzAutocompleteOptionComponent) fromDataSourceOptions!: QueryList<NzAutocompleteOptionComponent>;

/** cdk-overlay */
@ViewChild(TemplateRef, { static: false }) template: TemplateRef<{}>;
@ViewChild('panel', { static: false }) panel: ElementRef;
@ViewChild('content', { static: false }) content: ElementRef;
@ViewChild(TemplateRef, { static: false }) template?: TemplateRef<{}>;
@ViewChild('panel', { static: false }) panel?: ElementRef;
@ViewChild('content', { static: false }) content?: ElementRef;

private activeItemIndex: number = -1;
private selectionChangeSubscription = Subscription.EMPTY;
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
`
})
export class NzDemoAutoCompleteBasicComponent {
inputValue: string;
inputValue?: string;
options: string[] = [];

onInput(value: string): void {
Expand Down
4 changes: 2 additions & 2 deletions components/auto-complete/demo/certain-category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export interface AutocompleteOptionGroups {
]
})
export class NzDemoAutoCompleteCertainCategoryComponent implements OnInit {
inputValue: string;
optionGroups: AutocompleteOptionGroups[];
inputValue?: string;
optionGroups: AutocompleteOptionGroups[] = [];

constructor() {}

Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
`
})
export class NzDemoAutoCompleteCustomComponent {
inputValue: string;
inputValue?: string;
options: string[] = [];

onInput(value: string): void {
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/non-case-sensitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
`
})
export class NzDemoAutoCompleteNonCaseSensitiveComponent {
inputValue: string;
inputValue?: string;
filteredOptions: string[] = [];
options = ['Burns Bay Road', 'Downing Street', 'Wall Street'];

Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
`
})
export class NzDemoAutoCompleteOptionsComponent {
inputValue: string;
inputValue?: string;
options: string[] = [];

onInput(e: Event): void {
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/uncertain-category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { Component, ViewEncapsulation } from '@angular/core';
]
})
export class NzDemoAutoCompleteUncertainCategoryComponent {
inputValue: string;
inputValue?: string;
options: Array<{ value: string; category: string; count: number }> = [];

onChange(e: Event): void {
Expand Down
29 changes: 17 additions & 12 deletions components/avatar/avatar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import {
} from '@angular/core';

import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { NzShapeSCType, NzSizeLDSType } from 'ng-zorro-antd/core/types';
import {
NgClassInterface,
NgStyleInterface,
NzShapeSCType,
NzSizeLDSType
} from 'ng-zorro-antd/core/types';

const NZ_CONFIG_COMPONENT_NAME = 'avatar';

Expand All @@ -45,23 +50,23 @@ const NZ_CONFIG_COMPONENT_NAME = 'avatar';
encapsulation: ViewEncapsulation.None
})
export class NzAvatarComponent implements OnChanges {
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'circle') nzShape: NzShapeSCType;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzSizeLDSType | number;
@Input() nzText: string;
@Input() nzSrc: string;
@Input() nzSrcSet: string;
@Input() nzAlt: string;
@Input() nzIcon: string;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzShape: NzShapeSCType = 'circle';
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzSize: NzSizeLDSType | number = 'default';
@Input() nzText?: string;
@Input() nzSrc?: string;
@Input() nzSrcSet?: string;
@Input() nzAlt?: string;
@Input() nzIcon?: string;
@Output() readonly nzError = new EventEmitter<Event>();

hasText: boolean = false;
hasSrc: boolean = true;
hasIcon: boolean = false;
textStyles: {};
classMap: {};
textStyles: NgStyleInterface = {};
classMap: NgClassInterface = {};
customSize: string | null = null;

@ViewChild('textEl', { static: false }) textEl: ElementRef;
@ViewChild('textEl', { static: false }) textEl?: ElementRef;

private el: HTMLElement = this.elementRef.nativeElement;

Expand Down Expand Up @@ -116,7 +121,7 @@ export class NzAvatarComponent implements OnChanges {
return;
}

const childrenWidth = this.textEl.nativeElement.offsetWidth;
const childrenWidth = this.textEl!.nativeElement.offsetWidth;
const avatarWidth = this.el.getBoundingClientRect().width;
const scale = avatarWidth - 8 < childrenWidth ? (avatarWidth - 8) / childrenWidth : 1;
this.textStyles = {
Expand Down
6 changes: 3 additions & 3 deletions components/back-top/back-top.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export class NzBackTopComponent implements OnInit, OnDestroy, OnChanges {

visible: boolean = false;

@Input() nzTemplate: TemplateRef<void>;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 400) @InputNumber() nzVisibilityHeight: number;
@Input() nzTarget: string | HTMLElement;
@Input() nzTemplate?: TemplateRef<void>;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputNumber() nzVisibilityHeight: number = 400;
@Input() nzTarget?: string | HTMLElement;
@Output() readonly nzClick: EventEmitter<boolean> = new EventEmitter();

constructor(
Expand Down
4 changes: 2 additions & 2 deletions components/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export class NzButtonComponent implements OnDestroy, OnChanges, AfterViewInit, A
static ngAcceptInputType_nzLoading: BooleanInput;
static ngAcceptInputType_nzDanger: BooleanInput;

@ContentChild(NzIconDirective, { read: ElementRef }) nzIconDirectiveElement: ElementRef;
@ContentChild(NzIconDirective, { read: ElementRef }) nzIconDirectiveElement!: ElementRef;
@Input() @InputBoolean() nzBlock: boolean = false;
@Input() @InputBoolean() nzGhost: boolean = false;
@Input() @InputBoolean() nzSearch: boolean = false;
@Input() @InputBoolean() nzLoading: boolean = false;
@Input() @InputBoolean() nzDanger: boolean = false;
@Input() nzType: NzButtonType = null;
@Input() nzShape: NzButtonShape = null;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 'default') nzSize: NzButtonSize;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzSize: NzButtonSize = 'default';
private destroy$ = new Subject<void>();
private loading$ = new Subject<boolean>();

Expand Down
4 changes: 2 additions & 2 deletions components/calendar/calendar-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class NzCalendarHeaderComponent implements OnInit {

yearOffset: number = 10;
yearTotal: number = 20;
years: Array<{ label: string; value: number }>;
months: Array<{ label: string; value: number }>;
years: Array<{ label: string; value: number }> = [];
months: Array<{ label: string; value: number }> = [];

get activeYear(): number {
return this.activeDate.getYear();
Expand Down
26 changes: 13 additions & 13 deletions components/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class NzCalendarComponent implements ControlValueAccessor, OnChanges {
private onTouchFn: () => void = () => {};

@Input() nzMode: NzCalendarMode = 'month';
@Input() nzValue: Date;
@Input() nzValue?: Date;

@Output() readonly nzModeChange: EventEmitter<NzCalendarMode> = new EventEmitter();
@Output() readonly nzPanelChange: EventEmitter<{ date: Date; mode: NzCalendarMode }> = new EventEmitter();
Expand All @@ -108,28 +108,28 @@ export class NzCalendarComponent implements ControlValueAccessor, OnChanges {
* Cannot use @Input and @ContentChild on one variable
* because { static: false } will make @Input property get delayed
**/
@Input() nzDateCell: NzCalendarDateTemplate;
@ContentChild(DateCell, { static: false, read: TemplateRef }) nzDateCellChild: NzCalendarDateTemplate;
@Input() nzDateCell?: NzCalendarDateTemplate;
@ContentChild(DateCell, { static: false, read: TemplateRef }) nzDateCellChild?: NzCalendarDateTemplate;
get dateCell(): NzCalendarDateTemplate {
return this.nzDateCell || this.nzDateCellChild;
return (this.nzDateCell || this.nzDateCellChild)!;
}

@Input() nzDateFullCell: NzCalendarDateTemplate;
@ContentChild(DateFullCell, { static: false, read: TemplateRef }) nzDateFullCellChild: NzCalendarDateTemplate;
@Input() nzDateFullCell?: NzCalendarDateTemplate;
@ContentChild(DateFullCell, { static: false, read: TemplateRef }) nzDateFullCellChild?: NzCalendarDateTemplate;
get dateFullCell(): NzCalendarDateTemplate {
return this.nzDateFullCell || this.nzDateFullCellChild;
return (this.nzDateFullCell || this.nzDateFullCellChild)!;
}

@Input() nzMonthCell: NzCalendarDateTemplate;
@ContentChild(MonthCell, { static: false, read: TemplateRef }) nzMonthCellChild: NzCalendarDateTemplate;
@Input() nzMonthCell?: NzCalendarDateTemplate;
@ContentChild(MonthCell, { static: false, read: TemplateRef }) nzMonthCellChild?: NzCalendarDateTemplate;
get monthCell(): NzCalendarDateTemplate {
return this.nzMonthCell || this.nzMonthCellChild;
return (this.nzMonthCell || this.nzMonthCellChild)!;
}

@Input() nzMonthFullCell: NzCalendarDateTemplate;
@ContentChild(MonthFullCell, { static: false, read: TemplateRef }) nzMonthFullCellChild: NzCalendarDateTemplate;
@Input() nzMonthFullCell?: NzCalendarDateTemplate;
@ContentChild(MonthFullCell, { static: false, read: TemplateRef }) nzMonthFullCellChild?: NzCalendarDateTemplate;
get monthFullCell(): NzCalendarDateTemplate {
return this.nzMonthFullCell || this.nzMonthFullCellChild;
return (this.nzMonthFullCell || this.nzMonthFullCellChild)!;
}

@Input() @InputBoolean() nzFullscreen: boolean = true;
Expand Down
2 changes: 1 addition & 1 deletion components/card/card-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ import { ChangeDetectionStrategy, Component, TemplateRef, ViewChild, ViewEncapsu
`
})
export class NzCardTabComponent {
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<void>;
@ViewChild(TemplateRef, { static: true }) template!: TemplateRef<void>;
}
Loading

0 comments on commit d3a6438

Please sign in to comment.