Skip to content
This repository was archived by the owner on Jun 22, 2020. It is now read-only.

Commit 57b227f

Browse files
committed
feat: add strict tsconfig
1 parent 6b51ddd commit 57b227f

File tree

77 files changed

+538
-534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+538
-534
lines changed

helpers/mocks/simple-mock.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TableRow } from '../../projects/table-builder/src/lib/table/interfaces/
55
// noinspection AngularMissingOrInvalidDeclarationInModule
66
@Component({
77
selector: 'app',
8-
template: ` <ngx-table-builder [source]="data" [buffer-amount]="5"></ngx-table-builder> `
8+
template: ` <ngx-table-builder [source]="data"></ngx-table-builder> `
99
})
1010
export class SimpleMockComponent {
1111
public data: TableRow[] = [

helpers/utils/mocks-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-magic-numbers */
1+
/* eslint-disable no-magic-numbers,@typescript-eslint/no-magic-numbers */
22
import { TableRow } from '../../projects/table-builder/src/lib/table/interfaces/table-builder.external';
33
import { Any } from '../../projects/table-builder/src/lib/table/interfaces/table-builder.internal';
44
import { WebWorkerThreadService } from '../../projects/table-builder/src/lib/table/worker/worker-thread.service';

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@angular-devkit/build-angular": "0.803.26",
1717
"@angular-ru/eslint-config": "12.21.5",
1818
"@angular-ru/prettier-config": "12.19.1",
19+
"@angular-ru/tsconfig": "12.21.5",
1920
"@angular/animations": "8.2.14",
2021
"@angular/cdk": "8.2.3",
2122
"@angular/cli": "8.3.26",
@@ -30,11 +31,10 @@
3031
"@angular/platform-browser-dynamic": "8.2.14",
3132
"@angular/router": "8.2.14",
3233
"@types/jest": "24.0.13",
33-
"@types/node": "12.7.5",
34+
"@types/node": "14.0.13",
3435
"acorn": "6.1.1",
3536
"colors": "1.3.3",
3637
"core-js": "2.6.9",
37-
"eslint": "6.8.0",
3838
"hammerjs": "2.0.8",
3939
"husky": "3.0.5",
4040
"intersection-observer": "0.7.0",
@@ -49,7 +49,7 @@
4949
"ts-node": "7.0.0",
5050
"tsickle": "0.37.0",
5151
"tslib": "1.9.0",
52-
"typescript": "3.5.1",
52+
"typescript": "3.7.2",
5353
"zone.js": "0.10.2"
5454
}
5555
}

projects/table-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-ru/ng-table-builder",
3-
"version": "2.2.0",
3+
"version": "3.0.0",
44
"license": "MIT",
55
"bugs": {
66
"url": "https://github.com/Angular-RU/ng-table-builder/issues"

projects/table-builder/src/lib/table-builder.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import { UtilsService } from './table/services/utils/utils.service';
3333
import { TableBuilderComponent } from './table/table-builder.component';
3434
import { WebWorkerThreadService } from './table/worker/worker-thread.service';
3535

36-
if (window['Zone']) {
37-
(window as Any)[window['Zone'].__symbol__('MutationObserver')] = MutationObserver;
36+
if ((window as Any)['Zone']) {
37+
(window as Any)[(window as Any)['Zone'].__symbol__('MutationObserver')] = MutationObserver;
3838
}
3939

4040
@NgModule({

projects/table-builder/src/lib/table/components/common/column-options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export class ColumnOptions {
1313
@Input('overflow-tooltip') public overflowTooltip: boolean | null = null;
1414
@Input('filter-type') public filterType: TableFilterType | null = null;
1515
@Input() public nowrap: boolean | null = null;
16-
@Input() public width: number = null;
16+
@Input() public width: number | null = null;
1717
@Input('is-resizable') public isResizable: boolean | null = null;
1818
@Input('is-sortable') public isSortable: boolean | null = null;
1919
@Input('is-filterable') public isFilterable: boolean | null = null;
2020
@Input('is-draggable') public isDraggable: boolean | null = null;
21-
@Input('css-class') public cssClass: string[];
22-
@Input('css-style') public cssStyle: string[];
21+
@Input('css-class') public cssClass: string[] = [];
22+
@Input('css-style') public cssStyle: string[] = [];
2323
@Input() public stub: string | null = null;
2424
}

projects/table-builder/src/lib/table/components/common/modal-view-layer.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,27 @@ import { UtilsService } from '../../services/utils/utils.service';
1010
import { SCROLLBAR_WIDTH } from '../../symbols';
1111

1212
export interface PositionState {
13-
key: string;
14-
opened: boolean;
13+
key: string | null;
14+
opened: boolean | null;
1515
position: MousePosition;
1616
}
1717

18+
// eslint-disable-next-line
1819
export abstract class ModalViewLayer<T extends PositionState> implements OnDestroy {
19-
public width: number = null;
20-
public height: number = null;
20+
public width: number | null = null;
21+
public height: number | null = null;
2122
public isViewed: boolean = false;
2223
public isRendered: boolean = false;
23-
public minHeight: number;
24-
protected subscription: Subscription = null;
24+
public minHeight: number | null = null;
25+
protected subscription: Subscription | null = null;
2526
protected readonly app: ApplicationRef;
2627
protected readonly utils: UtilsService;
2728
protected readonly filterable: FilterableService;
2829
protected readonly ngZone: NgZone;
2930
protected readonly contextMenu: ContextMenuService;
3031

3132
@ViewChild('menu', { static: false })
32-
protected menu: ElementRef<HTMLDivElement>;
33+
protected menu!: ElementRef<HTMLDivElement>;
3334

3435
protected constructor(protected readonly cd: ChangeDetectorRef, injector: Injector) {
3536
this.app = injector.get<ApplicationRef>(ApplicationRef);
@@ -48,19 +49,19 @@ export abstract class ModalViewLayer<T extends PositionState> implements OnDestr
4849
}
4950

5051
public get overflowX(): number {
51-
const overflowX: number = this.width + this.left - this.utils.bodyRect.width;
52+
const overflowX: number = this.width! + this.left - this.utils.bodyRect?.width!;
5253
return overflowX > 0 ? overflowX + SCROLLBAR_WIDTH : 0;
5354
}
5455

5556
public get overflowY(): number {
56-
const overflowY: number = this.calculatedHeight + this.top - this.utils.bodyRect.height;
57+
const overflowY: number = this.calculatedHeight + this.top - this.utils.bodyRect?.height!;
5758
return overflowY > 0 ? overflowY + SCROLLBAR_WIDTH : 0;
5859
}
5960

6061
public abstract get state(): Partial<T>;
6162

6263
public get calculatedHeight(): number {
63-
let height: number;
64+
let height: number | null;
6465

6566
try {
6667
if (this.height) {
@@ -75,7 +76,7 @@ export abstract class ModalViewLayer<T extends PositionState> implements OnDestr
7576
height = this.height;
7677
}
7778

78-
return height;
79+
return height!;
7980
}
8081

8182
public updateView(): void {
@@ -90,8 +91,8 @@ export abstract class ModalViewLayer<T extends PositionState> implements OnDestr
9091
}
9192

9293
public ngOnDestroy(): void {
93-
if (!this.subscription.closed) {
94-
this.subscription.unsubscribe();
94+
if (!this.subscription?.closed) {
95+
this.subscription?.unsubscribe();
9596
}
9697
}
9798

@@ -100,7 +101,7 @@ export abstract class ModalViewLayer<T extends PositionState> implements OnDestr
100101
protected update(): void {
101102
this.ngZone.runOutsideAngular((): void => {
102103
window.setTimeout((): void => {
103-
this.isViewed = this.state.opened;
104+
this.isViewed = !!this.state.opened;
104105
this.updateView();
105106
window.setTimeout((): void => this.updateView());
106107
});

projects/table-builder/src/lib/table/components/common/table-content.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { TABLE_GLOBAL_OPTIONS } from '../../config/table-global-options';
44

55
export class TableContent {
66
@Input() public height: number = TABLE_GLOBAL_OPTIONS.ROW_HEIGHT;
7-
@Input('content-cell') public contentCell: boolean = null;
8-
@Input('align-center') public alignCenter: boolean = null;
9-
@Input('css-class') public cssClasses: string[] = null;
10-
@Input() public bold: boolean = null;
7+
@Input('content-cell') public contentCell: boolean | null = null;
8+
@Input('align-center') public alignCenter: boolean | null = null;
9+
@Input('css-class') public cssClasses: string[] = [];
10+
@Input() public bold: boolean | null = null;
1111
}

projects/table-builder/src/lib/table/components/ngx-column/ngx-column.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import { ColumnOptions } from '../common/column-options';
1111
encapsulation: ViewEncapsulation.None
1212
})
1313
export class NgxColumnComponent extends ColumnOptions {
14-
@Input() public key: string = null;
14+
@Input() public key: string | null = null;
1515
@Input() public stub: string = '-';
1616
@Input('sticky') public stickyLeft: boolean = false;
17-
@Input('empty-head') public emptyHead: boolean = null;
18-
@Input('head-title') public headTitle: string = null;
19-
@Input('custom-key') public customKey: boolean = false;
17+
@Input('empty-head') public emptyHead: boolean | null = null;
18+
@Input('head-title') public headTitle: string | null = null;
19+
@Input('custom-key') public customKey: boolean | string = false;
2020
@Input('sticky-end') public stickyRight: boolean = false;
2121
@Input('vertical-line') public verticalLine: boolean = false;
22-
@Input('important-template') public importantTemplate: boolean = false;
22+
@Input('important-template') public importantTemplate: boolean | string = false;
2323
@Input('overflow-tooltip') public overflowTooltip: boolean | null = null;
24-
@ContentChild(TemplateHeadThDirective, { static: false }) public th: TemplateHeadThDirective;
25-
@ContentChild(TemplateBodyTdDirective, { static: false }) public td: TemplateBodyTdDirective;
24+
@ContentChild(TemplateHeadThDirective, { static: false }) public th!: TemplateHeadThDirective;
25+
@ContentChild(TemplateBodyTdDirective, { static: false }) public td!: TemplateBodyTdDirective;
2626

2727
public withKey(key: string): NgxColumnComponent {
2828
this.key = key;

projects/table-builder/src/lib/table/components/ngx-context-menu/ngx-context-menu-item/ngx-context-menu-item.component.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ const MENU_WIDTH: number = 300;
3333
})
3434
export class NgxContextMenuItemComponent implements OnInit, OnDestroy {
3535
@Input() public visible: boolean = true;
36-
@Input() public contextTitle: boolean = null;
36+
@Input() public contextTitle: boolean | null = null;
3737
@Input() public disable: boolean = false;
3838
@Input() public divider: boolean = false;
3939
@Input('disable-sub-menu') public disableSubMenu: boolean = false;
4040
@Input('sub-menu-width') public subMenuWidth: number = MENU_WIDTH;
4141
@Output() public onClick: EventEmitter<ContextItemEvent> = new EventEmitter();
42-
@ViewChild('item', { static: false }) public itemRef: ElementRef<HTMLDivElement>;
43-
public offsetX: number = null;
44-
public offsetY: number = null;
45-
private subscription: Subscription;
46-
private taskId: number;
42+
@ViewChild('item', { static: false }) public itemRef: ElementRef<HTMLDivElement> | null = null;
43+
public offsetX: number | null = null;
44+
public offsetY: number | null = null;
45+
private subscription: Subscription | null = null;
46+
private taskId: number | null = null;
4747
private readonly contextMenu: ContextMenuService;
4848
private readonly utils: UtilsService;
4949
private readonly ngZone: NgZone;
@@ -87,21 +87,21 @@ export class NgxContextMenuItemComponent implements OnInit, OnDestroy {
8787
public calculateSubMenuPosition(ref: HTMLDivElement): void {
8888
const contentExist: boolean = ref.innerHTML.trim().length !== 0;
8989
if (contentExist) {
90-
this.offsetX = this.clientRect.left + this.subMenuWidth - MIN_PADDING_CONTEXT_ITEM;
90+
this.offsetX = this.clientRect.left! + this.subMenuWidth - MIN_PADDING_CONTEXT_ITEM;
9191
this.offsetX = this.offsetX - this.overflowX();
92-
this.offsetY = this.clientRect.top - MIN_PADDING_CONTEXT_ITEM;
92+
this.offsetY = this.clientRect.top! - MIN_PADDING_CONTEXT_ITEM;
9393
this.offsetY = this.offsetY - this.overflowY(ref);
9494
this.deferUpdateView();
9595
}
9696
}
9797

9898
public overflowX(): number {
99-
const overflowX: number = this.subMenuWidth + this.offsetX - this.utils.bodyRect.width;
99+
const overflowX: number = this.subMenuWidth + this.offsetX! - this.utils.bodyRect?.width!;
100100
return overflowX > 0 ? overflowX + SCROLLBAR_WIDTH : 0;
101101
}
102102

103103
public overflowY(ref: HTMLDivElement): number {
104-
const overflowY: number = ref.offsetHeight + this.offsetY - this.utils.bodyRect.height;
104+
const overflowY: number = ref.offsetHeight + this.offsetY! - this.utils.bodyRect?.height!;
105105
return overflowY > 0 ? overflowY + SCROLLBAR_WIDTH : 0;
106106
}
107107

@@ -111,7 +111,7 @@ export class NgxContextMenuItemComponent implements OnInit, OnDestroy {
111111

112112
this.onClick.emit({
113113
preventDefault: (): void => {
114-
window.clearTimeout(this.taskId);
114+
window.clearTimeout(this.taskId!);
115115
}
116116
});
117117

@@ -127,7 +127,7 @@ export class NgxContextMenuItemComponent implements OnInit, OnDestroy {
127127

128128
private deferUpdateView(): void {
129129
this.ngZone.runOutsideAngular((): void => {
130-
window.clearInterval(this.taskId);
130+
window.clearInterval(this.taskId!);
131131
this.taskId = window.setTimeout((): void => detectChanges(this.cd));
132132
});
133133
}

0 commit comments

Comments
 (0)