From ffc82e0b1c3178bda3a31be358864b9a56c73440 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 5 Jun 2022 17:30:40 -0500 Subject: [PATCH] Improved typing for player.layers --- src/game/player.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/game/player.ts b/src/game/player.ts index 30f9a6c..506337d 100644 --- a/src/game/player.ts +++ b/src/game/player.ts @@ -3,6 +3,7 @@ import Decimal from "util/bignum"; import type { ProxiedWithState } from "util/proxies"; import { ProxyPath, ProxyState } from "util/proxies"; import { reactive, unref } from "vue"; +import type { Ref } from "vue"; import transientState from "./state"; export interface PlayerData { @@ -18,11 +19,23 @@ export interface PlayerData { keepGoing: boolean; modID: string; modVersion: string; - layers: Record>; + layers: Record>; } export type Player = ProxiedWithState; +export type LayerData = { + [P in keyof T]?: T[P] extends (infer U)[] + ? LayerData[] + : T[P] extends Record + ? never + : T[P] extends Ref + ? S + : T[P] extends object + ? LayerData + : T[P]; +}; + const state = reactive({ id: "", devSpeed: null,