-
Notifications
You must be signed in to change notification settings - Fork 27
feature/ts-strict/qgrid-ngx #614
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
base: master
Are you sure you want to change the base?
feature/ts-strict/qgrid-ngx #614
Conversation
| imports: [ | ||
| CommonModule, | ||
| ], | ||
| declarations: [CellHandlerComponent], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put back formatting.
It should be autoformatted on save
| if (e.hasChanges('status')) { | ||
| if (e.state.status === 'endBatch' && this.endBatchEdit) { | ||
| this.endBatchEdit(); | ||
| this.endBatchEdit = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if this will break something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be reverted
| if (this.parentHost) { | ||
| this.parentHost.column.children.push(column); | ||
| if (this.parentHost.column.children) { | ||
| this.parentHost.column.children.push(column); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually you can replace these lines with
this.parentHost.column.children?.push(column);
| .reduce((memo, key) => { | ||
| memo[key] = column[key]; | ||
| .filter(key => !isUndefined(this.key) && Object.prototype.hasOwnProperty.call(column, key)) | ||
| .reduce((memo: any, key: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo isn't any.
{ [key: string]: Column } if i got this right
| const { column } = this.selfHost; | ||
| if (column && column.source === 'template') { | ||
| this.columnList.delete(column.key); | ||
| if (!(column && column.source === 'template')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!column || column.source !== 'template' is more readable, as for me.
If there's no column OR coumn source is not template.
Same thing with column.key.
Btw, why you even need to change this condition?
if (column && column.key && column.source === 'template') {
this.columnList.delete(column.key);
}| context.width = host.clientWidth; | ||
| context.height = host.clientHeight; | ||
| if(host) { | ||
| context.width = host.clientWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove if (host) condition
context.width = host?.clientWidth;
context.height = host?.clientHeight;| if (target.column.type !== 'row-expand') { | ||
| if (this.toggleStatus.canExecute(target.row)) { | ||
| this.toggleStatus.execute(target.row); | ||
| const timestampNewValue = timestamp.newValue ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to add delay variable here
const delay = (timestamp.newValue || 0) - (timestamp.oldValue || 0);
if (firstClickTarget === target && delay <= dblClickInterval) {
...
}| @Input('q-grid-core-index') viewIndex: number; | ||
| @Input('q-grid-core-tr') model: any; | ||
| @Input('q-grid-core-source') source; | ||
| @Input('q-grid-core-source') source: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type BoxParts = keyof { body: Bag; head: Bag; foot: Bag };
OR
type BoxParts = 'body' | 'head' | 'foot';
...
@Input('q-grid-core-source') source: BoxParts;
...
this.plugin.table.box.bag[this.source as BoxParts]Btw, check if there's already an interface that describe this thing { body: Bag; head: Bag; foot: Bag } and use it if exist
| @Input('q-grid-core-index') index: number; | ||
| @Input('q-grid-core-trh') model: any; | ||
| @Input('q-grid-core-source') source; | ||
| @Input('q-grid-core-source') source: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here for BoxParts
packages/qgrid-ngx/tsconfig.json
Outdated
| @@ -0,0 +1,43 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need it, but the repository does not. Accidental commit.
- Fixed a bug with qgrid-core type
|
|
||
| observeReply(model.sceneChanged) | ||
| .subscribe(e => { | ||
| .subscribe((e: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e: GridEventArg<SceneState>
|
|
||
| observe(model.sceneChanged) | ||
| .subscribe(e => { | ||
| .subscribe((e: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e: GridEventArg<SceneState>
| exports: [ | ||
| BodyCoreComponent, | ||
| ], | ||
| exports: [BodyCoreComponent], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check indentation.
Should be as before
| export declare class Renderer { | ||
| defaultStrategy: RenderStrategy; | ||
| readonly rows: { left: any[]; right: any[]; mid: any[] }; | ||
| readonly rows: Record<string, any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd create an interface for left, right, mid object and use it here.
export interface RowsPosition {
left: any[];
mid: any[];
right: any[];
}
....
readonly rows: RowsPosition;Because Record<string, ...> could accept any string as a key;
| } | ||
|
|
||
| create(name) { | ||
| create(name: string): Layer | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why undefined? It always return a Layer. If it's not exist it will be created
| @@ -1,4 +1,4 @@ | |||
| import { Injectable } from '@angular/core'; | |||
| import { Component, Injectable } from '@angular/core'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component isn't used
| ngOnChanges(changes: SimpleChanges) { | ||
| if (changes['index']) { | ||
| if (this.port.getItemSize()) { | ||
| this.ngOnChanges = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm afraid this would break something.
If you can't assign this method to null create a flag variable and after first visit set it to true;
private onChangesRan = false;
...
ngOnChanges(changes: SimpleChanges) {
if (this.onChangesRan) {
return;
}
if (changes['index']) {
if (this.port.getItemSize()) {
this.onChangesRan = true;
}
}
}| ngOnChanges(changes: SimpleChanges) { | ||
| if (changes['index']) { | ||
| if (this.port.getItemSize()) { | ||
| this.ngOnChanges = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for onChanges here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done like that for the perfomance, vscroll need the best perfomance, and onChanges needs only once, but it calls a lot
| providers: [ | ||
| VscrollService, | ||
| ], | ||
| providers: [VscrollService], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indentation
| } | ||
|
|
||
| transform(data: any[], context: IVscrollContext): ObservableLike<any[]> { | ||
| transform(data: any[], context: IVscrollContext): ObservableLike<any> | PromiseLike<any> | SubjectLike<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method returns items$ which is always SubjectLike<any>, isn't it?
| static number(x: number, format: string): string; | ||
| static date(x: Date, format: string): string; | ||
| static currency(x: number, format: string): string; | ||
| static number(x: number, format: string): string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets discuss to use Nullable instead of string | null
|
|
||
| observe<TState>(event: Event<TState>): ObservableLike<TState>; | ||
| observeReply<TState>(event: Event<TState>): ObservableLike<TState>; | ||
| observe<TState>(event: Event<TState>): ObservableEvent<TState>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we change it to ObservableEvent? it should return the minimal required interface
| import { ColumnView } from '../view/column.view'; | ||
| import { RenderStrategy } from './render.strategy'; | ||
|
|
||
| export interface RowPosition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least it should be called something like RowsSite
| } | ||
|
|
||
| columnId(index: number, item: ColumnView) { | ||
| columnId(index: number, item: ColumnView): string | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shorly string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (e.hasChanges('status')) { | ||
| if (e.state.status === 'endBatch' && this.endBatchEdit) { | ||
| this.endBatchEdit(); | ||
| this.endBatchEdit = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be reverted
| @Input('q-grid-resize-path') path; | ||
| @Input('q-grid-can-resize') canResize; | ||
| @Input('q-grid-resize-selector') selector; | ||
| @Input('q-grid-resize') key?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ? here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @Input('q-grid-resize-selector') selector; | ||
| @Input('q-grid-resize') key?: string; | ||
| @Input('q-grid-resize-path') path: string; | ||
| @Input('q-grid-can-resize') canResize: (e: unknown) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's defenitly not unknown
|
|
||
| ngOnInit() { | ||
| this.plugin.table.box.bag[this.source].addRow(this); | ||
| this.plugin.table.box.bag[this.source as keyof { body: Bag; head: Bag; foot: Bag }].addRow(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyof typeof bag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @Input('q-grid-vscroll-port-y') context: VscrollContext; | ||
|
|
||
| layout: VscrollLayout = null; | ||
| layout: VscrollLayout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check if default value not affects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All ok. It's undefined in the OnInit hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if anywere there is a check on null but god undefined, it can be broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All ok. I couldn't find any code that checks if layout is null.
| } | ||
|
|
||
| transform(data: any[], context: IVscrollContext): ObservableLike<any[]> { | ||
| transform(data: any[], context: IVscrollContext): SubjectLike<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back to ObservableLike
| export declare function binarySearch<T>(list: Array<any>, value: any): number; | ||
| export declare function getTypeName(ctor: new () => any): string; | ||
|
|
||
| export declare type Nullable<T> = T | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets have a separate file types.d.ts in utility folder, with all those helper files
| @Input('q-grid-core-value') actualValue: any; | ||
| @Input('q-grid-core-label') actualLabel: any; | ||
| @Input('q-grid-core-value') actualValue: unknown; | ||
| @Input('q-grid-core-label') actualLabel: unknown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about that
| }) | ||
| export class CellHandlerComponent implements OnInit, AfterViewInit { | ||
| private endBatchEdit: () => void; | ||
| private endBatchEdit: (() => void) | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by default it undefined, and why Nullable is not used here?
| }) | ||
| export class DragDirective { | ||
| @Input('q-grid-drag-data') data: any; | ||
| @Input('q-grid-drag-data') data: unknown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure
| private stateAccessor: StateAccessor, | ||
| private modelBuilder: GridModelBuilder, | ||
| @Inject(DOCUMENT) private document: any, | ||
| @Inject(DOCUMENT) private document: Document, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it work? when you build it in prod?
| ) { } | ||
|
|
||
| find(keys: string | string[]): TemplateLink { | ||
| find(keys: string | string[]): TemplateLink | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullable
|
|
||
| @Input() key = ''; | ||
| @Input() context: any = null; | ||
| @Input() context: unknown = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure
|
|
||
| markup: { [key: string]: HTMLElement } = {}; | ||
| layout: VscrollLayout = null; | ||
| layout: VscrollLayout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure to remove default values is a good idea
| @Input('q-grid-vscroll-port-y') context: VscrollContext; | ||
|
|
||
| layout: VscrollLayout = null; | ||
| layout: VscrollLayout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if anywere there is a check on null but god undefined, it can be broken
| ngOnChanges(changes: SimpleChanges) { | ||
| if (changes['index']) { | ||
| if (this.port.getItemSize()) { | ||
| this.ngOnChanges = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done like that for the perfomance, vscroll need the best perfomance, and onChanges needs only once, but it calls a lot
| export class TdCoreDirective implements DomTd, OnInit, OnDestroy, OnChanges { | ||
| @Input('q-grid-core-value') actualValue: any; | ||
| @Input('q-grid-core-label') actualLabel: any; | ||
| @Input('q-grid-core-label') actualLabel: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required to be string
| }) | ||
| export class CellHandlerComponent implements OnInit, AfterViewInit { | ||
| private endBatchEdit: () => void; | ||
| private endBatchEdit: Nullable<() => void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's only Nullable but got undefined on start? how lint missed that?
| export class ColumnListService { | ||
| private host = new Lazy(() => { | ||
| const canCopy = (key: string, source, target) => | ||
| const canCopy = (key: string, source: any, target: any) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source, target - Partial<ColumnModel>
| @Input() labelPath: string; | ||
|
|
||
| @Input() itemLabel: (row: any, value?: any) => any; | ||
| @Input() itemLabel: (row: any, value?: unknown) => string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about string
| }) | ||
| export class DragDirective { | ||
| @Input('q-grid-drag-data') data: any; | ||
| @Input('q-grid-drag-data') data: string | number | undefined | Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it sohuld be data or unknown
|
|
||
| $implicit = this; | ||
| element: HTMLElement = null; | ||
| element: HTMLElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't remove default value here also HTMLELement should be changed to Nullable



No description provided.