Skip to content

Commit de8d25d

Browse files
committed
chore(ng10): Enforce strictness
1 parent bf70bb5 commit de8d25d

10 files changed

+481
-708
lines changed

src/lib/components/abstract.loader.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ import { Input, Directive } from '@angular/core';
1212
@Directive()
1313
export abstract class AbstractLoaderDirective {
1414

15-
@Input() public backgroundColor: string;
15+
@Input() public backgroundColor!: string;
1616
}

src/lib/components/ng-http-loader.component.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import { Spinkit } from '../spinkits';
2222
export class NgHttpLoaderComponent implements OnInit {
2323

2424
public spinkit = Spinkit;
25-
public isVisible$: Observable<boolean>;
25+
public isVisible$!: Observable<boolean>;
2626
private visibleUntil = Date.now();
2727

2828
@Input() public backdrop = true;
29-
@Input() public backgroundColor: string;
29+
@Input() public backgroundColor!: string;
3030
@Input() public debounceDelay = 0;
3131
@Input() public entryComponent: any = null;
3232
@Input() public extraDuration = 0;
@@ -35,11 +35,17 @@ export class NgHttpLoaderComponent implements OnInit {
3535
@Input() public filteredUrlPatterns: string[] = [];
3636
@Input() public minDuration = 0;
3737
@Input() public opacity = '.7';
38-
@Input() public spinner = Spinkit.skWave;
38+
@Input() public spinner: string | null = Spinkit.skWave;
3939

4040
constructor(private pendingRequestsInterceptor: PendingRequestsInterceptor, private spinnerVisibility: SpinnerVisibilityService) {
4141
}
4242

43+
public ngOnInit(): void {
44+
this.initIsvisibleObservable();
45+
this.nullifySpinnerIfEntryComponentIsDefined();
46+
this.initFilters();
47+
}
48+
4349
private initIsvisibleObservable(): void {
4450
const [showSpinner$, hideSpinner$] = partition(this.pendingRequestsInterceptor.pendingRequestsStatus$, h => h);
4551

@@ -55,12 +61,6 @@ export class NgHttpLoaderComponent implements OnInit {
5561
);
5662
}
5763

58-
public ngOnInit(): void {
59-
this.initIsvisibleObservable();
60-
this.nullifySpinnerIfEntryComponentIsDefined();
61-
this.initFilters();
62-
}
63-
6464
private nullifySpinnerIfEntryComponentIsDefined(): void {
6565
if (this.entryComponent) {
6666
this.spinner = null;
@@ -74,10 +74,6 @@ export class NgHttpLoaderComponent implements OnInit {
7474
}
7575

7676
private initFilteredUrlPatterns(): void {
77-
if (!(this.filteredUrlPatterns instanceof Array)) {
78-
throw new TypeError('`filteredUrlPatterns` must be an array.');
79-
}
80-
8177
if (!!this.filteredUrlPatterns.length) {
8278
this.filteredUrlPatterns.forEach(e =>
8379
this.pendingRequestsInterceptor.filteredUrlPatterns.push(new RegExp(e))
@@ -86,16 +82,10 @@ export class NgHttpLoaderComponent implements OnInit {
8682
}
8783

8884
private initFilteredMethods(): void {
89-
if (!(this.filteredMethods instanceof Array)) {
90-
throw new TypeError('`filteredMethods` must be an array.');
91-
}
9285
this.pendingRequestsInterceptor.filteredMethods = this.filteredMethods;
9386
}
9487

9588
private initFilteredHeaders(): void {
96-
if (!(this.filteredHeaders instanceof Array)) {
97-
throw new TypeError('`filteredHeaders` must be an array.');
98-
}
9989
this.pendingRequestsInterceptor.filteredHeaders = this.filteredHeaders;
10090
}
10191

src/lib/services/pending-requests-interceptor.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class PendingRequestsInterceptor implements HttpInterceptor {
2222
private _filteredUrlPatterns: RegExp[] = [];
2323
private _filteredMethods: string[] = [];
2424
private _filteredHeaders: string[] = [];
25-
private _forceByPass: boolean;
25+
private _forceByPass = false;
2626

2727
get pendingRequestsStatus$(): Observable<boolean> {
2828
return this._pendingRequestsStatus$.asObservable();

src/test/components/ng-http-loader.component.spec.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,6 @@ describe('NgHttpLoaderComponent', () => {
252252
expect(isVisible).toBeFalsy();
253253
}));
254254

255-
it('should throw an error if filteredUrlPatterns is not an array', () => {
256-
component.filteredUrlPatterns = null;
257-
expect(() => component.ngOnInit()).toThrow(new Error('`filteredUrlPatterns` must be an array.'));
258-
});
259-
260-
it('should throw an error if filteredMethods is not an array', () => {
261-
component.filteredMethods = null;
262-
expect(() => component.ngOnInit()).toThrow(new Error('`filteredMethods` must be an array.'));
263-
});
264-
265-
it('should throw an error if filteredHeaders is not an array', () => {
266-
component.filteredHeaders = null;
267-
expect(() => component.ngOnInit()).toThrow(new Error('`filteredHeaders` must be an array.'));
268-
});
269-
270255
it('should show the spinner even if the component is created after the HTTP request is performed', fakeAsync(() => {
271256
http.get('/fake').subscribe();
272257

src/test/ng-http-loader.module.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('NgHttpLoaderModule', () => {
2323

2424
it('should create an instance with providers via forRoot()', () => {
2525
const ngHttpLoaderModuleWithProviders = NgHttpLoaderModule.forRoot();
26+
// @ts-ignore
2627
expect(ngHttpLoaderModuleWithProviders.providers[0][0].useExisting.name).toEqual(PendingRequestsInterceptor.name);
2728
});
2829
});

tsconfig.base.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
"compilerOptions": {
44
"baseUrl": "./",
55
"outDir": "./dist/out-tsc",
6+
"forceConsistentCasingInFileNames": true,
7+
"strict": true,
8+
"noImplicitReturns": true,
9+
"noFallthroughCasesInSwitch": true,
610
"sourceMap": true,
711
"declaration": false,
812
"downlevelIteration": true,
913
"experimentalDecorators": true,
10-
"module": "esnext",
1114
"moduleResolution": "node",
1215
"importHelpers": true,
1316
"target": "es2015",
17+
"module": "es2020",
1418
"lib": [
1519
"es2018",
1620
"dom"
1721
]
1822
},
1923
"angularCompilerOptions": {
20-
"fullTemplateTypeCheck": true,
24+
"strictTemplates": true,
2125
"strictInjectionParameters": true
2226
}
2327
}

tsconfig.lib.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
12
{
23
"extends": "./tsconfig.base.json",
34
"compilerOptions": {
45
"outDir": "./out-tsc/lib",
56
"target": "es2015",
67
"declaration": true,
78
"inlineSources": true,
8-
"noImplicitAny": true,
9-
"noImplicitReturns": true,
109
"types": [],
1110
"lib": [
1211
"dom",

tsconfig.lib.prod.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
12
{
23
"extends": "./tsconfig.lib.json",
34
"angularCompilerOptions": {
45
"enableIvy": false
56
}
6-
}
7+
}

tsconfig.spec.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"compilerOptions": {
44
"outDir": "./out-tsc/spec",
55
"types": [
6-
"jasmine",
7-
"node"
6+
"jasmine"
87
]
98
},
109
"files": [

0 commit comments

Comments
 (0)