From 47d17730e07576d0b4ca382edeefd8726c03f974 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 17 Mar 2024 23:28:57 -0500 Subject: [PATCH] Update TS --- package-lock.json | 10 +++++----- package.json | 2 +- src/data/common.tsx | 3 ++- src/features/action.tsx | 2 +- src/features/clickables/clickable.ts | 4 ++-- src/features/conversion.ts | 4 ++-- src/features/feature.ts | 1 + src/features/trees/tree.ts | 8 ++++++-- src/game/requirements.tsx | 3 ++- src/util/vue.tsx | 5 +++-- tests/utils.ts | 13 +++++-------- tsconfig.json | 1 + 12 files changed, 31 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 337a179..45bb1ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "eslint": "^8.6.0", "jsdom": "^24.0.0", "prettier": "^2.5.1", - "typescript": "^5.0.2", + "typescript": "^5.4.2", "vitest": "^1.4.0", "vue-tsc": "^2.0.6" }, @@ -7435,16 +7435,16 @@ } }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", + "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/ufo": { diff --git a/package.json b/package.json index 4e23f99..71979db 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "eslint": "^8.6.0", "jsdom": "^24.0.0", "prettier": "^2.5.1", - "typescript": "^5.0.2", + "typescript": "^5.4.2", "vitest": "^1.4.0", "vue-tsc": "^2.0.6" }, diff --git a/src/data/common.tsx b/src/data/common.tsx index c1286a2..1518e02 100644 --- a/src/data/common.tsx +++ b/src/data/common.tsx @@ -28,6 +28,7 @@ import { convertComputable, processComputable } from "util/computed"; import { getFirstFeature, renderColJSX, renderJSX } from "util/vue"; import type { ComputedRef, Ref } from "vue"; import { computed, unref } from "vue"; +import { JSX } from "vue/jsx-runtime"; import "./common.css"; /** An object that configures a {@link ResetButton} */ @@ -128,7 +129,7 @@ export function createResetButton{" "} {resetButton.conversion.gainResource.displayName} - {unref(resetButton.showNextAt) != null ? ( + {unref(resetButton.showNextAt as ProcessedComputable) != null ? (

{unref(resetButton.conversion.buyMax) ? "Next:" : "Req:"}{" "} diff --git a/src/features/action.tsx b/src/features/action.tsx index 2919a9e..2b08e08 100644 --- a/src/features/action.tsx +++ b/src/features/action.tsx @@ -219,7 +219,7 @@ export function createAction( const onClick = action.onClick.bind(action); action.onClick = function () { - if (unref(action.canClick) === false) { + if (unref(action.canClick as ProcessedComputable) === false) { return; } const amount = Decimal.div(progress.value, unref(genericAction.duration)); diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index cfd578e..0af2886 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -129,7 +129,7 @@ export function createClickable( if (clickable.onClick) { const onClick = clickable.onClick.bind(clickable); clickable.onClick = function (e) { - if (unref(clickable.canClick) !== false) { + if (unref(clickable.canClick as ProcessedComputable) !== false) { onClick(e); } }; @@ -137,7 +137,7 @@ export function createClickable( if (clickable.onHold) { const onHold = clickable.onHold.bind(clickable); clickable.onHold = function () { - if (unref(clickable.canClick) !== false) { + if (unref(clickable.canClick as ProcessedComputable) !== false) { onHold(); } }; diff --git a/src/features/conversion.ts b/src/features/conversion.ts index 78ad7cd..09c85f4 100644 --- a/src/features/conversion.ts +++ b/src/features/conversion.ts @@ -228,7 +228,7 @@ export function createIndependentConversion( conversion.baseResource.value ) ).max(conversion.gainResource.value); - if (unref(conversion.buyMax) === false) { + if (unref(conversion.buyMax as ProcessedComputable) === false) { gain = gain.min(Decimal.add(conversion.gainResource.value, 1)); } return gain; @@ -245,7 +245,7 @@ export function createIndependentConversion( .floor() .max(0); - if (unref(conversion.buyMax) === false) { + if (unref(conversion.buyMax as ProcessedComputable) === false) { gain = gain.min(1); } return gain; diff --git a/src/features/feature.ts b/src/features/feature.ts index 429629a..e6aaecc 100644 --- a/src/features/feature.ts +++ b/src/features/feature.ts @@ -2,6 +2,7 @@ import Decimal from "util/bignum"; import { DoNotCache, ProcessedComputable } from "util/computed"; import type { CSSProperties, DefineComponent } from "vue"; import { isRef, unref } from "vue"; +import { JSX } from "vue/jsx-runtime"; /** * A symbol to use as a key for a vue component a feature can be rendered with diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index 5a03189..99b54e7 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -141,7 +141,9 @@ export function createTreeNode( if (treeNode.onClick) { const onClick = treeNode.onClick.bind(treeNode); treeNode.onClick = function (e) { - if (unref(treeNode.canClick) !== false) { + if ( + unref(treeNode.canClick as ProcessedComputable) !== false + ) { onClick(e); } }; @@ -149,7 +151,9 @@ export function createTreeNode( if (treeNode.onHold) { const onHold = treeNode.onHold.bind(treeNode); treeNode.onHold = function () { - if (unref(treeNode.canClick) !== false) { + if ( + unref(treeNode.canClick as ProcessedComputable) !== false + ) { onHold(); } }; diff --git a/src/game/requirements.tsx b/src/game/requirements.tsx index 363fccd..14cec2b 100644 --- a/src/game/requirements.tsx +++ b/src/game/requirements.tsx @@ -19,6 +19,7 @@ import { import { createLazyProxy } from "util/proxies"; import { joinJSX, renderJSX } from "util/vue"; import { computed, unref } from "vue"; +import { JSX } from "vue/jsx-runtime"; import Formula, { calculateCost, calculateMaxAffordable } from "./formulas/formulas"; import type { GenericFormula } from "./formulas/types"; import { DefaultValue, Persistent } from "./persistence"; @@ -179,7 +180,7 @@ export function createCostRequirement( ? calculateCost( req.cost, amount ?? 1, - unref(req.cumulativeCost) as boolean, + unref(req.cumulativeCost as ProcessedComputable), unref(req.directSum) as number ) : unref(req.cost as ProcessedComputable); diff --git a/src/util/vue.tsx b/src/util/vue.tsx index 3ba5f06..457e0b6 100644 --- a/src/util/vue.tsx +++ b/src/util/vue.tsx @@ -4,9 +4,9 @@ import type { CoercableComponent, GenericComponent, JSXFunction } from "features import { Component as ComponentKey, GatherProps, + Visibility, isVisible, - jsx, - Visibility + jsx } from "features/feature"; import type { ProcessedComputable } from "util/computed"; import { DoNotCache } from "util/computed"; @@ -21,6 +21,7 @@ import { unref, watchEffect } from "vue"; +import { JSX } from "vue/jsx-runtime"; import { camelToKebab } from "./common"; export function coerceComponent( diff --git a/tests/utils.ts b/tests/utils.ts index 4252eac..34dd471 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -6,14 +6,11 @@ interface CustomMatchers { toLogError(): R; } -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Vi { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Assertion extends CustomMatchers {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface AsymmetricMatchersContaining extends CustomMatchers {} - } +declare module "vitest" { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface Assertion extends CustomMatchers {} + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface AsymmetricMatchersContaining extends CustomMatchers {} } expect.extend({ diff --git a/tsconfig.json b/tsconfig.json index 280a1e1..a4e5495 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "strict": true, "checkJs": false, "jsx": "preserve", + "jsxImportSource": "vue", "importHelpers": true, "moduleResolution": "node", "resolveJsonModule": true,