Improved tooltip typing

This commit is contained in:
thepaperpilot 2022-04-23 14:32:43 -05:00
parent 5b45642a58
commit 6ed9f3da53

View file

@ -15,7 +15,7 @@ import {
ProcessedComputable ProcessedComputable
} from "util/computed"; } from "util/computed";
import { VueFeature } from "util/vue"; import { VueFeature } from "util/vue";
import { readonly, ref, Ref } from "vue"; import { Ref } from "vue";
import { persistent } from "game/persistence"; import { persistent } from "game/persistence";
declare module "@vue/runtime-dom" { declare module "@vue/runtime-dom" {
@ -49,7 +49,8 @@ export interface BaseTooltip {
export type Tooltip<T extends TooltipOptions> = Replace< export type Tooltip<T extends TooltipOptions> = Replace<
T & BaseTooltip, T & BaseTooltip,
{ {
pinnable: T["pinnable"] extends unknown ? true : T["pinnable"]; pinnable: T["pinnable"] extends undefined ? false : T["pinnable"];
pinned: T["pinnable"] extends true ? Ref<boolean> : undefined;
display: GetComputableType<T["display"]>; display: GetComputableType<T["display"]>;
classes: GetComputableType<T["classes"]>; classes: GetComputableType<T["classes"]>;
style: GetComputableType<T["style"]>; style: GetComputableType<T["style"]>;
@ -63,6 +64,7 @@ export type GenericTooltip = Replace<
Tooltip<TooltipOptions>, Tooltip<TooltipOptions>,
{ {
pinnable: boolean; pinnable: boolean;
pinned: Ref<boolean> | undefined;
direction: ProcessedComputable<TooltipDirection>; direction: ProcessedComputable<TooltipDirection>;
} }
>; >;