From 2ec1a03d8ff55d8d5f508f46a792bd5c0c20b4a8 Mon Sep 17 00:00:00 2001 From: thepaperpilot <thepaperpilot@gmail.com> Date: Tue, 10 May 2022 19:39:39 -0500 Subject: [PATCH] Fixed some typings on Board component also removed FeatureComponent type since it's no longer used --- src/features/boards/Board.vue | 34 +++++++++++++++++++++++++++------- src/features/feature.ts | 10 +--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/features/boards/Board.vue b/src/features/boards/Board.vue index 51d7f8b..a0cb8ae 100644 --- a/src/features/boards/Board.vue +++ b/src/features/boards/Board.vue @@ -25,7 +25,7 @@ <svg class="stage" width="100%" height="100%"> <g class="g1"> <transition-group name="link" appear> - <g v-for="(link, i) in links || []" :key="i"> + <g v-for="(link, i) in unref(links) || []" :key="i"> <BoardLinkVue :link="link" /> </g> </transition-group> @@ -38,8 +38,8 @@ :dragged="dragged" :hasDragged="hasDragged" :receivingNode="receivingNode?.id === node.id" - :selectedNode="selectedNode" - :selectedAction="selectedAction" + :selectedNode="unref(selectedNode)" + :selectedAction="unref(selectedAction)" @mouseDown="mouseDown" @endDragging="endDragging" /> @@ -51,15 +51,35 @@ </template> <script setup lang="ts"> -import { BoardNode, GenericBoard, getNodeProperty } from "features/boards/board"; -import { FeatureComponent, Visibility } from "features/feature"; +import { + BoardData, + BoardNode, + BoardNodeLink, + GenericBoardNodeAction, + GenericNodeType, + getNodeProperty +} from "features/boards/board"; +import { StyleValue, Visibility } from "features/feature"; import { PersistentState } from "game/persistence"; -import { computed, ref, toRefs } from "vue"; +import { ProcessedComputable } from "util/computed"; +import { computed, Ref, ref, toRefs, unref } from "vue"; import panZoom from "vue-panzoom"; import BoardLinkVue from "./BoardLink.vue"; import BoardNodeVue from "./BoardNode.vue"; -const _props = defineProps<FeatureComponent<GenericBoard>>(); +const _props = defineProps<{ + nodes: Ref<BoardNode[]>; + types: Record<string, GenericNodeType>; + [PersistentState]: Ref<BoardData>; + visibility: ProcessedComputable<Visibility>; + width?: ProcessedComputable<string>; + height?: ProcessedComputable<string>; + style?: ProcessedComputable<StyleValue>; + classes?: ProcessedComputable<Record<string, boolean>>; + links: Ref<BoardNodeLink[] | null>; + selectedAction: Ref<GenericBoardNodeAction | null>; + selectedNode: Ref<BoardNode | null>; +}>(); const props = toRefs(_props); const lastMousePosition = ref({ x: 0, y: 0 }); diff --git a/src/features/feature.ts b/src/features/feature.ts index 65c03bb..60631dd 100644 --- a/src/features/feature.ts +++ b/src/features/feature.ts @@ -1,6 +1,5 @@ -import { DefaultValue } from "game/persistence"; import Decimal from "util/bignum"; -import { DoNotCache, ProcessedComputable } from "util/computed"; +import { DoNotCache } from "util/computed"; import { CSSProperties, DefineComponent, isRef } from "vue"; export const Component = Symbol("Component"); @@ -15,13 +14,6 @@ export type StyleValue = string | CSSProperties | Array<string | CSSProperties>; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type GenericComponent = DefineComponent<any, any, any>; -export type FeatureComponent<T> = Omit< - { - [K in keyof T]: T[K] extends ProcessedComputable<infer S> ? S : T[K]; - }, - typeof Component | typeof DefaultValue ->; - export type Replace<T, S> = S & Omit<T, keyof S>; export type OptionsFunc<T, S = T, R = Record<string, unknown>> = () => T & ThisType<S> & Partial<R>;