Skip to content

Commit

Permalink
fix: Increase strictness on TileMap subtree
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Jul 5, 2024
1 parent 30bd1c5 commit 98fcb32
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Applied increased TS strictness for the TileMap API subtree

<!--------------------------------- DO NOT EDIT BELOW THIS LINE --------------------------------->
<!--------------------------------- DO NOT EDIT BELOW THIS LINE --------------------------------->
Expand Down
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ module.exports = (config) => {
// Excalibur logs / console logs suppressed when captureConsole = false;
captureConsole: false,
jasmine: {
random: true,
random: true,
seed: 98733,// 53435 // 98733
timeoutInterval: 70000 // needs to be bigger than no-activity
}
},
Expand Down
12 changes: 6 additions & 6 deletions src/engine/TileMap/IsometricMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class IsometricMap extends Entity {

public pointer: PointerComponent;

private _composite: CompositeCollider;
private _composite!: CompositeCollider;

constructor(options: IsometricMapOptions) {
super(
Expand Down Expand Up @@ -378,10 +378,10 @@ export class IsometricMap extends Entity {
};

private _setupPointerToTile() {
this.events.on('pointerup', this._forwardPointerEventToTile('pointerup'));
this.events.on('pointerdown', this._forwardPointerEventToTile('pointerdown'));
this.events.on('pointermove', this._forwardPointerEventToTile('pointermove'));
this.events.on('pointercancel', this._forwardPointerEventToTile('pointercancel'));
this.events.on('pointerup', this._forwardPointerEventToTile('pointerup') as any);
this.events.on('pointerdown', this._forwardPointerEventToTile('pointerdown') as any);
this.events.on('pointermove', this._forwardPointerEventToTile('pointermove') as any);
this.events.on('pointercancel', this._forwardPointerEventToTile('pointercancel') as any);
}

public update(): void {
Expand All @@ -403,7 +403,7 @@ export class IsometricMap extends Entity {
this._originalOffsets.set(collider, originalOffset);
return originalOffset;
} else {
return this._originalOffsets.get(collider);
return this._originalOffsets.get(collider) ?? Vector.Zero;
}
}
public updateColliders() {
Expand Down
18 changes: 9 additions & 9 deletions src/engine/TileMap/TileMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const TileMapEvents = {
export class TileMap extends Entity {
public events = new EventEmitter<TileMapEvents>();
private _token = 0;
private _engine: Engine;
private _engine!: Engine;

public logger: Logger = Logger.getInstance();
public readonly tiles: Tile[] = [];
Expand Down Expand Up @@ -162,7 +162,7 @@ export class TileMap extends Entity {
}
}

private _oldRotation: number;
private _oldRotation: number = 0;
public get rotation(): number {
return this.transform?.rotation ?? 0;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ export class TileMap extends Entity {
public off(eventName: string, handler: Handler<unknown>): void;
public off(eventName: string): void;
public off<TEventName extends EventKey<TileMapEvents> | string>(eventName: TEventName, handler?: Handler<any>): void {
this.events.off(eventName, handler);
this.events.off(eventName, handler as any);
}

/**
Expand Down Expand Up @@ -336,7 +336,7 @@ export class TileMap extends Entity {
this._originalOffsets.set(collider, originalOffset);
return originalOffset;
} else {
return this._originalOffsets.get(collider);
return this._originalOffsets.get(collider) ?? Vector.Zero;
}
}

Expand All @@ -348,7 +348,7 @@ export class TileMap extends Entity {
this._composite.clearColliders();
const colliders: BoundingBox[] = [];
this._composite = this.collider.useCompositeCollider([]);
let current: BoundingBox;
let current: BoundingBox | null = null;

/**
* Returns wether or not the 2 boxes share an edge and are the same height
Expand Down Expand Up @@ -535,7 +535,7 @@ export class TileMap extends Entity {
const tiles: Tile[] = [];
for (let x = tileStartX; x <= tileEndX; x++) {
for (let y = tileStartY; y <= tileEndY; y++) {
tiles.push(this.getTile(x, y));
tiles.push(this.getTile(x, y)!);
}
}
return tiles;
Expand Down Expand Up @@ -684,9 +684,9 @@ export interface TileOptions {
* use transparency to create layers this way.
*/
export class Tile {
private _bounds: BoundingBox;
private _geometry: BoundingBox;
private _pos: Vector;
private _bounds!: BoundingBox;
private _geometry!: BoundingBox;
private _pos!: Vector;
private _posDirty = false;

public events = new EventEmitter<TilePointerEvents>();
Expand Down
6 changes: 6 additions & 0 deletions src/engine/TileMap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"strict": true
}
}

0 comments on commit 98fcb32

Please sign in to comment.