fix new TS errors

This commit is contained in:
jakub791 2023-05-04 19:40:03 +02:00
parent 6540546432
commit 2e449f2b78
8 changed files with 36 additions and 22 deletions

View file

@ -11,7 +11,7 @@ import {
BoundsInjectionKey BoundsInjectionKey
} from "game/layers"; } from "game/layers";
import type { FeatureNode } from "game/layers"; import type { FeatureNode } from "game/layers";
import { nextTick, onMounted, provide, ref } from "vue"; import { Ref, nextTick, onMounted, provide, ref } from "vue";
import { globalBus } from "game/events"; import { globalBus } from "game/events";
const emit = defineEmits<{ const emit = defineEmits<{
@ -21,7 +21,7 @@ const emit = defineEmits<{
const nodes = ref<Record<string, FeatureNode | undefined>>({}); const nodes = ref<Record<string, FeatureNode | undefined>>({});
const resizeObserver = new ResizeObserver(updateBounds); const resizeObserver = new ResizeObserver(updateBounds);
const resizeListener = ref<Element | null>(null); const resizeListener = ref<Element | null>(null) as Ref<Element | null>;
onMounted(() => { onMounted(() => {
// ResizeListener exists because ResizeObserver's don't work when told to observe an SVG element // ResizeListener exists because ResizeObserver's don't work when told to observe an SVG element
const resListener = resizeListener.value; const resListener = resizeListener.value;
@ -30,7 +30,7 @@ onMounted(() => {
} }
}); });
let isDirty = true; let isDirty = true;
let boundingRect = ref(resizeListener.value?.getBoundingClientRect()); const boundingRect = ref(resizeListener.value?.getBoundingClientRect());
function updateBounds() { function updateBounds() {
if (isDirty) { if (isDirty) {
isDirty = false; isDirty = false;

View file

@ -4,8 +4,15 @@
<div class="header"> <div class="header">
<h2>Settings</h2> <h2>Settings</h2>
<div class="option-tabs"> <div class="option-tabs">
<button :class="{selected: isTab('behaviour')}" @click="setTab('behaviour')">Behaviour</button> <button :class="{ selected: isTab('behaviour') }" @click="setTab('behaviour')">
<button :class="{selected: isTab('appearance')}" @click="setTab('appearance')">Appearance</button> Behaviour
</button>
<button
:class="{ selected: isTab('appearance') }"
@click="setTab('appearance')"
>
Appearance
</button>
</div> </div>
</div> </div>
</template> </template>
@ -15,7 +22,9 @@
<Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" /> <Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" />
<Toggle :title="offlineProdTitle" v-model="offlineProd" /> <Toggle :title="offlineProdTitle" v-model="offlineProd" />
<Toggle :title="autosaveTitle" v-model="autosave" /> <Toggle :title="autosaveTitle" v-model="autosave" />
<FeedbackButton v-if="!autosave" class="button save-button" @click="save()">Manually save</FeedbackButton> <FeedbackButton v-if="!autosave" class="button save-button" @click="save()"
>Manually save</FeedbackButton
>
</div> </div>
<div v-if="isTab('appearance')"> <div v-if="isTab('appearance')">
<Select :title="themeTitle" :options="themes" v-model="theme" /> <Select :title="themeTitle" :options="themes" v-model="theme" />
@ -69,7 +78,7 @@ const themes = Object.keys(rawThemes).map(theme => ({
})); }));
const settingFieldsComponent = computed(() => { const settingFieldsComponent = computed(() => {
return coerceComponent(jsx(() => (<>{settingFields.map(render)}</>))); return coerceComponent(jsx(() => <>{settingFields.map(render)}</>));
}); });
const { showTPS, theme, unthrottled, alignUnits } = toRefs(settings); const { showTPS, theme, unthrottled, alignUnits } = toRefs(settings);
@ -91,19 +100,28 @@ const unthrottledTitle = jsx(() => (
)); ));
const offlineProdTitle = jsx(() => ( const offlineProdTitle = jsx(() => (
<span class="option-title"> <span class="option-title">
Offline Production<Tooltip display="Save-specific" direction={Direction.Right}>*</Tooltip> Offline Production
<Tooltip display="Save-specific" direction={Direction.Right}>
*
</Tooltip>
<desc>Simulate production that occurs while the game is closed.</desc> <desc>Simulate production that occurs while the game is closed.</desc>
</span> </span>
)); ));
const autosaveTitle = jsx(() => ( const autosaveTitle = jsx(() => (
<span class="option-title"> <span class="option-title">
Autosave<Tooltip display="Save-specific" direction={Direction.Right}>*</Tooltip> Autosave
<Tooltip display="Save-specific" direction={Direction.Right}>
*
</Tooltip>
<desc>Automatically save the game every second or when the game is closed.</desc> <desc>Automatically save the game every second or when the game is closed.</desc>
</span> </span>
)); ));
const isPausedTitle = jsx(() => ( const isPausedTitle = jsx(() => (
<span class="option-title"> <span class="option-title">
Pause game<Tooltip display="Save-specific" direction={Direction.Right}>*</Tooltip> Pause game
<Tooltip display="Save-specific" direction={Direction.Right}>
*
</Tooltip>
<desc>Stop everything from moving.</desc> <desc>Stop everything from moving.</desc>
</span> </span>
)); ));

View file

@ -30,7 +30,7 @@ import { coerceComponent, isCoercableComponent, render } from "util/vue";
import { computed, Ref, ref, unref } from "vue"; import { computed, Ref, ref, unref } from "vue";
import { BarOptions, createBar, GenericBar } from "./bars/bar"; import { BarOptions, createBar, GenericBar } from "./bars/bar";
import { ClickableOptions } from "./clickables/clickable"; import { ClickableOptions } from "./clickables/clickable";
import { Decorator, GenericDecorator } from "./decorators/common"; import { GenericDecorator } from "./decorators/common";
/** A symbol used to identify {@link Action} features. */ /** A symbol used to identify {@link Action} features. */
export const ActionType = Symbol("Action"); export const ActionType = Symbol("Action");

View file

@ -47,7 +47,8 @@ export default defineComponent({
resizeTo: resListener, resizeTo: resListener,
backgroundAlpha: 0 backgroundAlpha: 0
}); });
resizeListener.value?.appendChild(app.value.view); // I think it's supporsed to be a canvas element
resizeListener.value?.appendChild(app.value.view as HTMLCanvasElement);
props.onInit?.(app.value as Application); props.onInit?.(app.value as Application);
} }
updateBounds(); updateBounds();

View file

@ -19,7 +19,7 @@ import { createLazyProxy } from "util/proxies";
import { joinJSX, renderJSX } from "util/vue"; import { joinJSX, renderJSX } from "util/vue";
import { computed, unref } from "vue"; import { computed, unref } from "vue";
import Formula, { calculateCost, calculateMaxAffordable } from "./formulas/formulas"; import Formula, { calculateCost, calculateMaxAffordable } from "./formulas/formulas";
import type { GenericFormula, InvertibleFormula } from "./formulas/types"; import type { GenericFormula } from "./formulas/types";
import { DefaultValue, Persistent } from "./persistence"; import { DefaultValue, Persistent } from "./persistence";
/** /**

View file

@ -1,7 +0,0 @@
import { Application } from "@pixi/app";
import { BatchRenderer, Renderer } from "@pixi/core";
import { TickerPlugin } from "@pixi/ticker";
Application.registerPlugin(TickerPlugin);
Renderer.registerPlugin("batch", BatchRenderer);

View file

@ -125,7 +125,9 @@ export function setupHoldToClick(
handleHolding: VoidFunction; handleHolding: VoidFunction;
} { } {
const interval = ref<NodeJS.Timer | null>(null); const interval = ref<NodeJS.Timer | null>(null);
const event = ref<MouseEvent | TouchEvent | undefined>(undefined); const event = ref<MouseEvent | TouchEvent | undefined>(undefined) as Ref<
MouseEvent | TouchEvent | undefined
>;
function start(e: MouseEvent | TouchEvent) { function start(e: MouseEvent | TouchEvent) {
if (!interval.value) { if (!interval.value) {

View file

@ -1,5 +1,5 @@
import Decimal, { DecimalSource, format } from "util/bignum"; import Decimal, { DecimalSource, format } from "util/bignum";
import { expect, Assertion } from "vitest"; import { expect } from "vitest";
interface CustomMatchers<R = unknown> { interface CustomMatchers<R = unknown> {
compare_tolerance(expected: DecimalSource, tolerance?: number): R; compare_tolerance(expected: DecimalSource, tolerance?: number): R;