mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-28 19:11:42 +00:00
Improved typing for player.layers
This commit is contained in:
parent
b6d5eaa72d
commit
9370b0ed6f
1 changed files with 14 additions and 1 deletions
|
@ -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<string, Record<string, unknown>>;
|
||||
layers: Record<string, LayerData<unknown>>;
|
||||
}
|
||||
|
||||
export type Player = ProxiedWithState<PlayerData>;
|
||||
|
||||
export type LayerData<T> = {
|
||||
[P in keyof T]?: T[P] extends (infer U)[]
|
||||
? LayerData<U>[]
|
||||
: T[P] extends Record<string, never>
|
||||
? never
|
||||
: T[P] extends Ref<infer S>
|
||||
? S
|
||||
: T[P] extends object
|
||||
? LayerData<T[P]>
|
||||
: T[P];
|
||||
};
|
||||
|
||||
const state = reactive<PlayerData>({
|
||||
id: "",
|
||||
devSpeed: null,
|
||||
|
|
Loading…
Reference in a new issue