Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add noImplicitAny noImplicitThis strictFunctionTypes #3019

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ describe('affix', () => {
});

describe('(nzChange)', () => {
let changeValue;
let changeValue: boolean;
beforeEach(() => {
component.nzChange.subscribe((returnValue) => {
component.nzChange.subscribe((returnValue: boolean) => {
changeValue = returnValue;
});
});
Expand Down
22 changes: 11 additions & 11 deletions components/alert/nz-alert.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, TemplateRef, ViewChild } from '@angular/core';
import { fakeAsync, tick, TestBed } from '@angular/core/testing';
import { Component, DebugElement, TemplateRef, ViewChild } from '@angular/core';
import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

Expand All @@ -15,9 +15,9 @@ describe('alert', () => {
TestBed.compileComponents();
}));
describe('basic alert', () => {
let fixture;
let testComponent;
let alert;
let fixture: ComponentFixture<NzDemoTestBasicComponent>;
let testComponent: NzDemoTestBasicComponent;
let alert: DebugElement;
beforeEach(() => {
fixture = TestBed.createComponent(NzDemoTestBasicComponent);
fixture.detectChanges();
Expand Down Expand Up @@ -100,8 +100,8 @@ describe('alert', () => {
});
});
describe('banner alert', () => {
let fixture;
let alert;
let fixture: ComponentFixture<NzDemoTestBannerComponent>;
let alert: DebugElement;

beforeEach(() => {
fixture = TestBed.createComponent(NzDemoTestBannerComponent);
Expand Down Expand Up @@ -138,11 +138,11 @@ export class NzDemoTestBasicComponent {
@ViewChild('template') template: TemplateRef<void>;
banner = false;
closeable = false;
closeText;
description = 'description';
message = 'message';
closeText: string | TemplateRef<void>;
description: string | TemplateRef<void> = 'description';
message: string | TemplateRef<void> = 'message';
showIcon = false;
iconType;
iconType: string;
type = 'info';
onClose = jasmine.createSpy('close callback');
}
Expand Down
39 changes: 20 additions & 19 deletions components/auto-complete/nz-autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ViewChild,
ViewChildren
} from '@angular/core';
import { async, fakeAsync, flush, inject, tick, TestBed } from '@angular/core/testing';
import { async, fakeAsync, flush, inject, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, FormBuilder, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand Down Expand Up @@ -74,8 +74,8 @@ describe('auto-complete', () => {
}));

describe('toggling', () => {
let fixture;
let input;
let fixture: ComponentFixture<NzTestSimpleAutocompleteComponent>;
let input: HTMLInputElement;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestSimpleAutocompleteComponent);
Expand Down Expand Up @@ -196,6 +196,7 @@ describe('auto-complete', () => {

trigger.openPanel();
fixture.detectChanges();
// @ts-ignore
trigger.destroyPanel();

expect(() => trigger.closePanel()).not.toThrow();
Expand Down Expand Up @@ -271,8 +272,8 @@ describe('auto-complete', () => {
});

describe('property', () => {
let fixture;
let input;
let fixture: ComponentFixture<NzTestAutocompletePropertyComponent>;
let input: HTMLInputElement;
let DOWN_ARROW_EVENT: KeyboardEvent;
let ENTER_EVENT: KeyboardEvent;
let TAB_EVENT: KeyboardEvent;
Expand Down Expand Up @@ -394,8 +395,8 @@ describe('auto-complete', () => {
});

describe('value', () => {
let fixture;
let input;
let fixture: ComponentFixture<NzTestSimpleAutocompleteComponent>;
let input: HTMLInputElement;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestSimpleAutocompleteComponent);
Expand Down Expand Up @@ -465,7 +466,7 @@ describe('auto-complete', () => {
});

describe('form', () => {
let fixture;
let fixture: ComponentFixture<NzTestAutocompleteWithFormComponent>;
let input: HTMLInputElement;

beforeEach(() => {
Expand All @@ -477,7 +478,7 @@ describe('auto-complete', () => {
it('should set the value with form', () => {
const componentInstance = fixture.componentInstance;
fixture.detectChanges();
expect(componentInstance.form.get('formControl').value)
expect(componentInstance.form.get('formControl')!.value)
.toContain('Burns');
expect(input.value)
.toContain('Burns');
Expand Down Expand Up @@ -517,8 +518,8 @@ describe('auto-complete', () => {
});

describe('option groups', () => {
let fixture;
let input;
let fixture: ComponentFixture<NzTestAutocompleteGroupComponent>;
let input: HTMLInputElement;
let DOWN_ARROW_EVENT: KeyboardEvent;
let ENTER_EVENT: KeyboardEvent;

Expand Down Expand Up @@ -561,7 +562,7 @@ describe('auto-complete', () => {
});

describe('Option selection', () => {
let fixture;
let fixture: ComponentFixture<NzTestSimpleAutocompleteComponent>;

beforeEach((() => {
fixture = TestBed.createComponent(NzTestSimpleAutocompleteComponent);
Expand Down Expand Up @@ -627,8 +628,8 @@ describe('auto-complete', () => {
});

describe('keyboard events', () => {
let fixture;
let input;
let fixture: ComponentFixture<NzTestSimpleAutocompleteComponent>;
let input: HTMLInputElement;
let DOWN_ARROW_EVENT: KeyboardEvent;
let UP_ARROW_EVENT: KeyboardEvent;
let ENTER_EVENT: KeyboardEvent;
Expand Down Expand Up @@ -830,7 +831,7 @@ describe('auto-complete', () => {
});

describe('Fallback positions', () => {
let fixture;
let fixture: ComponentFixture<NzTestSimpleAutocompleteComponent>;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestSimpleAutocompleteComponent);
Expand Down Expand Up @@ -877,7 +878,7 @@ describe('auto-complete', () => {
});

describe('misc', () => {
let fixture;
let fixture: ComponentFixture<NzTestAutocompleteWithoutPanelComponent>;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestAutocompleteWithoutPanelComponent);
Expand Down Expand Up @@ -932,9 +933,9 @@ describe('auto-complete', () => {
})
class NzTestSimpleAutocompleteComponent {
inputValue: string;
filteredOptions: string[];
filteredOptions: Array<string | number>;
inputControl = new FormControl();
options = ['Burns Bay Road', 'Downing Street', 'Wall Street'];
options: Array<string | number> = ['Burns Bay Road', 'Downing Street', 'Wall Street'];

@ViewChild(NzAutocompleteComponent) panel: NzAutocompleteComponent;
@ViewChild(NzAutocompleteTriggerDirective) trigger: NzAutocompleteTriggerDirective;
Expand All @@ -945,7 +946,7 @@ class NzTestSimpleAutocompleteComponent {
}

onInput(value: string): void {
this.filteredOptions = this.options.filter(s => new RegExp(value, 'gi').test(s));
this.filteredOptions = this.options.filter(s => new RegExp(value, 'gi').test(`${s}`));
}
}

Expand Down
8 changes: 6 additions & 2 deletions components/avatar/nz-avatar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import {
} from '@angular/core';

import { NzUpdateHostClassService } from '../core/services/update-host-class.service';
import { NzSizeLDSType } from '../core/types/size';
import { NzSizeLDSType, NzSizeMap } from '../core/types/size';

export type NzAvatarShape = 'square' | 'circle';
export type NzAvatarSize = NzSizeLDSType | number;

export interface NzAvatarSizeMap {
[ size: string ]: string;
}

@Component({
selector : 'nz-avatar',
templateUrl : './nz-avatar.component.html',
Expand Down Expand Up @@ -44,7 +48,7 @@ export class NzAvatarComponent implements OnChanges {

private el: HTMLElement = this.elementRef.nativeElement;
private prefixCls = 'ant-avatar';
private sizeMap = { large: 'lg', small: 'sm' };
private sizeMap: NzSizeMap = { large: 'lg', small: 'sm' };

constructor(
private elementRef: ElementRef,
Expand Down
2 changes: 1 addition & 1 deletion components/back-top/back-top.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('Component:nz-back-top', () => {

describe('when clicked', () => {
it(`emit event on nzClick`, fakeAsync(() => {
component.nzClick.subscribe((returnValue) => {
component.nzClick.subscribe((returnValue: boolean) => {
expect(returnValue).toBe(true);
});

Expand Down
33 changes: 22 additions & 11 deletions components/badge/nz-badge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Component } from '@angular/core';
import { fakeAsync, tick, TestBed } from '@angular/core/testing';
import { Component, DebugElement } from '@angular/core';
import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { NGStyleInterface } from '../core/types/ng-class';

import { NzBadgeComponent } from './nz-badge.component';
import { NzBadgeModule } from './nz-badge.module';

Expand All @@ -14,33 +16,37 @@ describe('badge', () => {
});
TestBed.compileComponents();
}));

describe('basic badge', () => {
let fixture;
let testComponent;
let badgeElement;
let fixture: ComponentFixture<NzTestBadgeBasicComponent>;
let testComponent: NzTestBadgeBasicComponent;
let badgeElement: DebugElement;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestBadgeBasicComponent);
fixture.detectChanges();
testComponent = fixture.debugElement.componentInstance;
badgeElement = fixture.debugElement.query(By.directive(NzBadgeComponent));
});

it('should className correct', () => {
fixture.detectChanges();
expect(badgeElement.nativeElement.classList).toContain('ant-badge');
});

it('should count work', () => {
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('sup').classList).toContain('ant-scroll-number');
expect(badgeElement.nativeElement.querySelector('sup').classList).toContain('ant-badge-count');
expect(badgeElement.nativeElement.querySelector('sup').classList).not.toContain('ant-badge-multiple-words');
console.log(badgeElement.nativeElement);
expect(badgeElement.nativeElement.querySelector('.current').innerText).toBe('5');
testComponent.count = 10;
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('sup').classList).toContain('ant-badge-multiple-words');
expect(badgeElement.nativeElement.querySelectorAll('.current')[ 0 ].innerText).toBe('1');
expect(badgeElement.nativeElement.querySelectorAll('.current')[ 1 ].innerText).toBe('0');
});

it('should overflow work', () => {
testComponent.overflow = 4;
fixture.detectChanges();
Expand All @@ -54,6 +60,7 @@ describe('badge', () => {
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('sup').innerText).not.toBe('99+');
});

it('should showZero work', fakeAsync(() => {
testComponent.count = 0;
fixture.detectChanges();
Expand All @@ -64,6 +71,7 @@ describe('badge', () => {
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('.current').innerText).toBe('0');
}));

it('should negative number not display', fakeAsync(() => {
testComponent.count = -10;
fixture.detectChanges();
Expand All @@ -74,13 +82,15 @@ describe('badge', () => {
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('.current').innerText).toBe('0');
}));

it('should dot work', () => {
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('sup').classList).not.toContain('ant-badge-dot');
testComponent.dot = true;
fixture.detectChanges();
expect(badgeElement.nativeElement.querySelector('sup').classList).toContain('ant-badge-dot');
});

it('should no wrapper work', fakeAsync(() => {
testComponent.inner = false;
testComponent.style = { backgroundColor: '#52c41a' };
Expand All @@ -92,6 +102,7 @@ describe('badge', () => {
// expect(badgeElement.nativeElement.classList).toContain('ant-badge-not-a-wrapper');
expect(badgeElement.nativeElement.querySelector('sup').style.backgroundColor).toBe('rgb(82, 196, 26)');
}));

it('should status work', () => {
testComponent.inner = false;
const statusList = [ 'success', 'processing', 'default', 'error', 'warning' ];
Expand Down Expand Up @@ -123,12 +134,12 @@ describe('badge', () => {
`
})
export class NzTestBadgeBasicComponent {
style;
count = 5;
dot = false;
inner = true;
overflow = 20;
showZero = false;
inner = true;
status;
text;
dot = false;
status: string;
style: NGStyleInterface;
text: string;
}
Loading