Skip to content

Commit 064447b

Browse files
authored
Merge pull request #2530 from Ruslan207/fix/strict–engine-interface
fix(typings): make engine interface strict
2 parents 85db1e0 + 5319756 commit 064447b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/gridstack-engine.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class GridStackEngine {
4040
/** @internal cached layouts of difference column count so we can restore back (eg 12 -> 1 -> 12) */
4141
protected _layouts?: GridStackNode[][]; // maps column # to array of values nodes
4242
/** @internal true while we are resizing widgets during column resize to skip certain parts */
43-
protected _inColumnResize: boolean;
43+
protected _inColumnResize?: boolean;
4444
/** @internal true if we have some items locked */
4545
protected _hasLocked: boolean;
4646
/** @internal unique global internal _id counter */
@@ -127,7 +127,7 @@ export class GridStackEngine {
127127
}
128128

129129
/** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */
130-
public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode {
130+
public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode | undefined {
131131
const skipId = skip._id;
132132
const skip2Id = skip2?._id;
133133
return this.nodes.find(n => n._id !== skipId && n._id !== skip2Id && Utils.isIntercepted(n, area));
@@ -139,7 +139,7 @@ export class GridStackEngine {
139139
}
140140

141141
/** does a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line */
142-
protected directionCollideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode {
142+
protected directionCollideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode | undefined {
143143
if (!o.rect || !node._rect) return;
144144
let r0 = node._rect; // where started
145145
let r = {...o.rect}; // where we are
@@ -218,7 +218,7 @@ export class GridStackEngine {
218218
}
219219

220220
/** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */
221-
public swap(a: GridStackNode, b: GridStackNode): boolean {
221+
public swap(a: GridStackNode, b: GridStackNode): boolean | undefined {
222222
if (!b || b.locked || !a || a.locked) return false;
223223

224224
function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)
@@ -953,7 +953,7 @@ export class GridStackEngine {
953953
return this;
954954
}
955955

956-
protected findCacheLayout(n: GridStackNode, column: number): number {
956+
protected findCacheLayout(n: GridStackNode, column: number): number | undefined {
957957
return this._layouts?.[column]?.findIndex(l => l._id === n._id) ?? -1;
958958
}
959959

0 commit comments

Comments
 (0)