Skip to content

Commit

Permalink
fix(hex): when overriding a hex prototype method, this is now corre…
Browse files Browse the repository at this point in the history
  • Loading branch information
flauwekeul committed Apr 22, 2021
1 parent 43d0109 commit 8df5488
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/hex/functions/createHexPrototype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ const assertOffset = ({ offset }: HexPrototypeOptions) => {
return offset
}

export const createHexPrototype = <T extends DefaultHexPrototype>(
customPrototype?: T | Partial<HexPrototypeOptions>,
) => {
export const createHexPrototype = <T extends Hex>(customPrototype?: T | Partial<HexPrototypeOptions>) => {
// pseudo private property
const s = new WeakMap()

const prototype = {
...defaultHexSettings,
copy(newProps = {}) {
copy(newProps) {
return copyHex(this, newProps)
},
// fixme: make this a getter and name it `asPoint`, or better: add getters for x and y
Expand Down
4 changes: 2 additions & 2 deletions src/hex/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export interface DefaultHexPrototype extends HexSettings {
s: number

// todo: about 80% sure the newProps type works (it's used in more places, if it works: maybe make it a separate type?)
copy<T extends Hex>(this: T, newProps?: Partial<T> | HexCoordinates): T
toPoint<T extends Hex>(this: T): Point
copy(this: this, newProps?: Partial<this> | HexCoordinates): this
toPoint(this: this): Point
}

export interface Hex extends DefaultHexPrototype, AxialCoordinates {}

0 comments on commit 8df5488

Please sign in to comment.