Skip to content

Commit

Permalink
Remove strictNullChecks: false WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Jul 30, 2024
1 parent 8804bf4 commit d80d7b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
40 changes: 22 additions & 18 deletions src/ScrollBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,32 @@ type ProximityEventData = {

export class ScrollBox extends Container
{
protected background: Graphics;
protected borderMask: Graphics;
protected lastWidth: number;
protected lastHeight: number;
protected background!: Graphics;
protected borderMask!: Graphics;
protected lastWidth!: number;
protected lastHeight!: number;
protected __width = 0;
protected __height = 0;
protected _dimensionChanged = false;

protected list: List;
protected list!: List;

protected _trackpad: Trackpad;
protected _trackpad!: Trackpad;
protected isDragging = 0;
protected interactiveStorage: {
item: Container;
eventMode: EventMode;
}[] = [];
protected visibleItems: Container[] = [];
protected pressedChild: Container;
protected pressedChild!: Container | null;
protected ticker = Ticker.shared;
protected options: ScrollBoxOptions;
protected stopRenderHiddenItemsTimeout!: NodeJS.Timeout;
protected options!: ScrollBoxOptions;
protected stopRenderHiddenItemsTimeout!: NodeJS.Timeout | null;
protected onMouseScrollBinding = this.onMouseScroll.bind(this);
protected dragStarTouchPoint: Point;
protected dragStarTouchPoint!: Point;
protected isOver = false;

protected proximityRange: number;
protected proximityRange!: number;
protected proximityStatusCache: boolean[] = [];
protected lastScrollX!: number | null;
protected lastScrollY!: number | null;
Expand Down Expand Up @@ -168,7 +168,9 @@ export class ScrollBox extends Container
rightPadding: options.rightPadding,
});

this.addItems(options.items);
if (options.items) {
this.addItems(options.items);
}

if (this.hasBounds)
{
Expand Down Expand Up @@ -486,7 +488,7 @@ export class ScrollBox extends Container
0,
this.__width,
this.__height,
this.options.radius | 0,
this.options.radius ?? 0,
)
.fill(0xff00ff)
.stroke(0x0);
Expand All @@ -501,7 +503,7 @@ export class ScrollBox extends Container
0,
this.__width,
this.__height,
this.options.radius | 0,
this.options.radius ?? 0,
)
.fill({
color: color ?? 0x000000,
Expand Down Expand Up @@ -649,8 +651,10 @@ export class ScrollBox extends Container

protected renderAllItems()
{
clearTimeout(this.stopRenderHiddenItemsTimeout);
this.stopRenderHiddenItemsTimeout = null;
if (this.stopRenderHiddenItemsTimeout) {
clearTimeout(this.stopRenderHiddenItemsTimeout);
this.stopRenderHiddenItemsTimeout = null;
}

if (this.options.disableDynamicRendering)
{
Expand Down Expand Up @@ -866,8 +870,8 @@ export class ScrollBox extends Container
if (item.eventMode !== 'auto')
{
isMobile.any
? item.emit('pointerupoutside', null)
: item.emit('mouseupoutside', null);
? item.emit('pointerupoutside', null as any)
: item.emit('mouseupoutside', null as any);

this.interactiveStorage.push({
item,
Expand Down
8 changes: 4 additions & 4 deletions src/SliderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export type DoubleSliderOptions = BaseSliderOptions & {
/** Hepper class, used as a base for single or double slider creation. */
export class SliderBase extends ProgressBar
{
protected _slider1: Container;
protected _slider2: Container;
protected _slider1!: Container;
protected _slider2!: Container;

protected value1Text?: PixiText;
protected value2Text?: PixiText;

protected _value1: number;
protected _value2: number;
protected _value1!: number;
protected _value2!: number;

protected dragging = 0;

Expand Down
16 changes: 10 additions & 6 deletions src/Switcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Switcher extends Container
innerView: Container;

/** The id of the visible(active) view. */
protected _active: number;
protected _active!: number | undefined;

/** Fired when active view changes. */
onChange: Signal<(state: number | boolean) => void>;
Expand Down Expand Up @@ -75,7 +75,7 @@ export class Switcher extends Container
/** Returns the active view. */
get activeView(): Container | undefined
{
if (this.views && this.views[this.active])
if (this.views && this.active && this.views[this.active])
{
return this.views[this.active] as Container;
}
Expand Down Expand Up @@ -158,7 +158,9 @@ export class Switcher extends Container
{
const res = this.views.length > 2 ? this.active : this.active === 1;

this.onChange.emit(res);
if (res) {
this.onChange.emit(res);
}
}
}

Expand Down Expand Up @@ -187,15 +189,17 @@ export class Switcher extends Container
return;
}

this.views[this.active].visible = true;
if (this.active) {
this.views[this.active].visible = true;
}
}

/** Returns the id of the next view in order. Or undefined, if order is empty. */
protected get nextActive(): number | undefined
{
if (this.views.length === 0) return undefined;

return this.active < this.views.length - 1 ? this.active + 1 : 0;
return this.active ? this.active < this.views.length - 1 ? this.active + 1 : 0 : 0;
}

/** Sets the id of the visible(active) view and shows to it. */
Expand All @@ -205,7 +209,7 @@ export class Switcher extends Container
}

/** Gets the id of the visible(active) view. */
get active(): number
get active(): number | undefined
{
return this._active;
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"strictNullChecks": false,
"strictNullChecks": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"noImplicitOverride": true
Expand Down

0 comments on commit d80d7b5

Please sign in to comment.