Skip to content

Commit

Permalink
Change grid template type
Browse files Browse the repository at this point in the history
  • Loading branch information
xShadowBlade committed Jun 11, 2024
1 parent dda8423 commit 5b64ae8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dist/types/classes/Grid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { UnknownObject } from "../common/types";
* Represents a grid cell with coordinates and properties.
* @template P - The type of the properties of the grid cell.
*/
declare class GridCell<P extends UnknownObject = UnknownObject> {
declare class GridCell<P extends object = UnknownObject> {
/** The x-coordinate of the cell. */
x: number;
/** The y-coordinate of the cell. */
Expand All @@ -32,13 +32,13 @@ declare class GridCell<P extends UnknownObject = UnknownObject> {
* @param name - The name of the property.
* @returns - The value of the property.
*/
getValue(name: string): unknown;
getValue(name: keyof P): P[keyof P];
}
/**
* Represents a grid with cells.
* @template P - The type of the properties of the grid cells.
*/
declare class Grid<P extends UnknownObject = UnknownObject> {
declare class Grid<P extends object = UnknownObject> {
/** The size of the grid along the x-axis. */
xSize: number;
/** The size of the grid along the x-axis. */
Expand Down
6 changes: 3 additions & 3 deletions src/classes/Grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { UnknownObject } from "../common/types";
* Represents a grid cell with coordinates and properties.
* @template P - The type of the properties of the grid cell.
*/
class GridCell<P extends UnknownObject = UnknownObject> {
class GridCell<P extends object = UnknownObject> {
/** The x-coordinate of the cell. */
public x: number;

Expand Down Expand Up @@ -45,7 +45,7 @@ class GridCell<P extends UnknownObject = UnknownObject> {
* @param name - The name of the property.
* @returns - The value of the property.
*/
public getValue (name: string): unknown {
public getValue (name: keyof P): P[keyof P] {
return this.properties[name];
}
}
Expand All @@ -54,7 +54,7 @@ class GridCell<P extends UnknownObject = UnknownObject> {
* Represents a grid with cells.
* @template P - The type of the properties of the grid cells.
*/
class Grid<P extends UnknownObject = UnknownObject> {
class Grid<P extends object = UnknownObject> {
/** The size of the grid along the x-axis. */
public xSize: number;

Expand Down

0 comments on commit 5b64ae8

Please sign in to comment.