From 9370b0ed6f3904d29d213e05709e9d173bf2b418 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,