Skip to content

Commit

Permalink
Fix Grid get/set typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyd committed Jan 25, 2024
1 parent a5d8e41 commit 1a5c3cc
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/data-structures/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,46 @@ export class Grid {
}

/**
* @template T the datatype that has been set in the grid for this position
* @overload
* @param {Vector2} x
* @returns {?} "TODO@v1" attempt to get this template-ized
* @returns {T}
*/
/**
* @template T the datatype that has been set in the grid for this position
* @overload
* @param {Integer} x
* @param {Integer} y
* @returns {?}
* @returns {T}
*/
/**
* @template T the datatype that has been set in the grid for this position
* @param {Integer | Vector2} x
* @param {Integer} [y]
* @returns {?}
* @returns {T}
*/
get(x, y) {
// @ts-expect-error TS can't handle overloads calling overloads
return this.#grid[this.#index(x, y)]
}


/**
* @template T the datatype to hold in this position
* @overload
* @param {Vector2} vec
* @param {T} value
* @returns {void}
*/
/**
* @template T the datatype to hold in this position
* @overload
* @param {Integer} x
* @param {Integer} y
* @param {T} value
* @returns {void}
*/
/**
* TODO@v1: add overload notations
* @param {[number, number, any] | [Vector2, any]} args
* @returns {void}
*/
Expand Down

0 comments on commit 1a5c3cc

Please sign in to comment.