From e4144046eedb7fadd6c07ad6a06fd0a3b64799d6 Mon Sep 17 00:00:00 2001 From: blujai831 Date: Thu, 10 Oct 2024 19:41:44 -0700 Subject: [PATCH] Remove Properties utility type and use Pick directly instead, because Properties includes a class's methods, not just its properties, which is not desired, but cannot be worked around at this time, because TypeScript currently offers no way to form a union type of only those instance properties of a type which equal undefined on its prototype, presumably because a prototype is a value, not a type, and only types can be queried at compile time because that's the simple and straightforward way for it to work, in spite of the fact that the initial state of a class's prototype object at runtime *could* be statically calculated at compile time by analyzing the class's structure, if they *wanted* to, harumpf harumpf. --- src/GameUpgrade.ts | 11 +++++++++-- src/util.ts | 6 ------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/GameUpgrade.ts b/src/GameUpgrade.ts index aff4db37..fc5f5407 100644 --- a/src/GameUpgrade.ts +++ b/src/GameUpgrade.ts @@ -1,6 +1,5 @@ import {IGameState} from "./IGameState.ts"; import {IGameUpgrade} from "./IGameUpgrade.ts"; -import {Properties} from "./util.ts"; /** * See IGameUpgrade. @@ -93,7 +92,15 @@ export class GameUpgrade implements IGameUpgrade { * the instance's properties, mimicking C/++'s designated initializers. * @param properties Keyword arguments / property donor object. */ - public constructor(properties: Properties) { + public constructor(properties: Pick) { Object.assign(this, properties); } } \ No newline at end of file diff --git a/src/util.ts b/src/util.ts index 0cb2dc0d..9bd6c4cc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,9 +1,3 @@ -/** - * Gets the type of a plain object that has the same properties - * as an instance of the given class. - */ -export type Properties = Pick; - /** * Applies an appropriate ordinal suffix to the given number * (i.e. "-st", "-nd", "-rd", or "-th").