Update TS

This commit is contained in:
thepaperpilot 2024-03-17 23:28:57 -05:00
parent a908c81ccf
commit 47d17730e0
12 changed files with 31 additions and 25 deletions

10
package-lock.json generated
View file

@ -43,7 +43,7 @@
"eslint": "^8.6.0", "eslint": "^8.6.0",
"jsdom": "^24.0.0", "jsdom": "^24.0.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"typescript": "^5.0.2", "typescript": "^5.4.2",
"vitest": "^1.4.0", "vitest": "^1.4.0",
"vue-tsc": "^2.0.6" "vue-tsc": "^2.0.6"
}, },
@ -7435,16 +7435,16 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.0.4", "version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"devOptional": true, "devOptional": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
}, },
"engines": { "engines": {
"node": ">=12.20" "node": ">=14.17"
} }
}, },
"node_modules/ufo": { "node_modules/ufo": {

View file

@ -50,7 +50,7 @@
"eslint": "^8.6.0", "eslint": "^8.6.0",
"jsdom": "^24.0.0", "jsdom": "^24.0.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"typescript": "^5.0.2", "typescript": "^5.4.2",
"vitest": "^1.4.0", "vitest": "^1.4.0",
"vue-tsc": "^2.0.6" "vue-tsc": "^2.0.6"
}, },

View file

@ -28,6 +28,7 @@ import { convertComputable, processComputable } from "util/computed";
import { getFirstFeature, renderColJSX, renderJSX } from "util/vue"; import { getFirstFeature, renderColJSX, renderJSX } from "util/vue";
import type { ComputedRef, Ref } from "vue"; import type { ComputedRef, Ref } from "vue";
import { computed, unref } from "vue"; import { computed, unref } from "vue";
import { JSX } from "vue/jsx-runtime";
import "./common.css"; import "./common.css";
/** An object that configures a {@link ResetButton} */ /** An object that configures a {@link ResetButton} */
@ -128,7 +129,7 @@ export function createResetButton<T extends ClickableOptions & ResetButtonOption
)} )}
</b>{" "} </b>{" "}
{resetButton.conversion.gainResource.displayName} {resetButton.conversion.gainResource.displayName}
{unref(resetButton.showNextAt) != null ? ( {unref(resetButton.showNextAt as ProcessedComputable<boolean>) != null ? (
<div> <div>
<br /> <br />
{unref(resetButton.conversion.buyMax) ? "Next:" : "Req:"}{" "} {unref(resetButton.conversion.buyMax) ? "Next:" : "Req:"}{" "}

View file

@ -219,7 +219,7 @@ export function createAction<T extends ActionOptions>(
const onClick = action.onClick.bind(action); const onClick = action.onClick.bind(action);
action.onClick = function () { action.onClick = function () {
if (unref(action.canClick) === false) { if (unref(action.canClick as ProcessedComputable<boolean>) === false) {
return; return;
} }
const amount = Decimal.div(progress.value, unref(genericAction.duration)); const amount = Decimal.div(progress.value, unref(genericAction.duration));

View file

@ -129,7 +129,7 @@ export function createClickable<T extends ClickableOptions>(
if (clickable.onClick) { if (clickable.onClick) {
const onClick = clickable.onClick.bind(clickable); const onClick = clickable.onClick.bind(clickable);
clickable.onClick = function (e) { clickable.onClick = function (e) {
if (unref(clickable.canClick) !== false) { if (unref(clickable.canClick as ProcessedComputable<boolean>) !== false) {
onClick(e); onClick(e);
} }
}; };
@ -137,7 +137,7 @@ export function createClickable<T extends ClickableOptions>(
if (clickable.onHold) { if (clickable.onHold) {
const onHold = clickable.onHold.bind(clickable); const onHold = clickable.onHold.bind(clickable);
clickable.onHold = function () { clickable.onHold = function () {
if (unref(clickable.canClick) !== false) { if (unref(clickable.canClick as ProcessedComputable<boolean>) !== false) {
onHold(); onHold();
} }
}; };

View file

@ -228,7 +228,7 @@ export function createIndependentConversion<S extends ConversionOptions>(
conversion.baseResource.value conversion.baseResource.value
) )
).max(conversion.gainResource.value); ).max(conversion.gainResource.value);
if (unref(conversion.buyMax) === false) { if (unref(conversion.buyMax as ProcessedComputable<boolean>) === false) {
gain = gain.min(Decimal.add(conversion.gainResource.value, 1)); gain = gain.min(Decimal.add(conversion.gainResource.value, 1));
} }
return gain; return gain;
@ -245,7 +245,7 @@ export function createIndependentConversion<S extends ConversionOptions>(
.floor() .floor()
.max(0); .max(0);
if (unref(conversion.buyMax) === false) { if (unref(conversion.buyMax as ProcessedComputable<boolean>) === false) {
gain = gain.min(1); gain = gain.min(1);
} }
return gain; return gain;

View file

@ -2,6 +2,7 @@ import Decimal from "util/bignum";
import { DoNotCache, ProcessedComputable } from "util/computed"; import { DoNotCache, ProcessedComputable } from "util/computed";
import type { CSSProperties, DefineComponent } from "vue"; import type { CSSProperties, DefineComponent } from "vue";
import { isRef, unref } 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 * A symbol to use as a key for a vue component a feature can be rendered with

View file

@ -141,7 +141,9 @@ export function createTreeNode<T extends TreeNodeOptions>(
if (treeNode.onClick) { if (treeNode.onClick) {
const onClick = treeNode.onClick.bind(treeNode); const onClick = treeNode.onClick.bind(treeNode);
treeNode.onClick = function (e) { treeNode.onClick = function (e) {
if (unref(treeNode.canClick) !== false) { if (
unref(treeNode.canClick as ProcessedComputable<boolean | undefined>) !== false
) {
onClick(e); onClick(e);
} }
}; };
@ -149,7 +151,9 @@ export function createTreeNode<T extends TreeNodeOptions>(
if (treeNode.onHold) { if (treeNode.onHold) {
const onHold = treeNode.onHold.bind(treeNode); const onHold = treeNode.onHold.bind(treeNode);
treeNode.onHold = function () { treeNode.onHold = function () {
if (unref(treeNode.canClick) !== false) { if (
unref(treeNode.canClick as ProcessedComputable<boolean | undefined>) !== false
) {
onHold(); onHold();
} }
}; };

View file

@ -19,6 +19,7 @@ import {
import { createLazyProxy } from "util/proxies"; 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 { JSX } from "vue/jsx-runtime";
import Formula, { calculateCost, calculateMaxAffordable } from "./formulas/formulas"; import Formula, { calculateCost, calculateMaxAffordable } from "./formulas/formulas";
import type { GenericFormula } from "./formulas/types"; import type { GenericFormula } from "./formulas/types";
import { DefaultValue, Persistent } from "./persistence"; import { DefaultValue, Persistent } from "./persistence";
@ -179,7 +180,7 @@ export function createCostRequirement<T extends CostRequirementOptions>(
? calculateCost( ? calculateCost(
req.cost, req.cost,
amount ?? 1, amount ?? 1,
unref(req.cumulativeCost) as boolean, unref(req.cumulativeCost as ProcessedComputable<boolean>),
unref(req.directSum) as number unref(req.directSum) as number
) )
: unref(req.cost as ProcessedComputable<DecimalSource>); : unref(req.cost as ProcessedComputable<DecimalSource>);

View file

@ -4,9 +4,9 @@ import type { CoercableComponent, GenericComponent, JSXFunction } from "features
import { import {
Component as ComponentKey, Component as ComponentKey,
GatherProps, GatherProps,
Visibility,
isVisible, isVisible,
jsx, jsx
Visibility
} from "features/feature"; } from "features/feature";
import type { ProcessedComputable } from "util/computed"; import type { ProcessedComputable } from "util/computed";
import { DoNotCache } from "util/computed"; import { DoNotCache } from "util/computed";
@ -21,6 +21,7 @@ import {
unref, unref,
watchEffect watchEffect
} from "vue"; } from "vue";
import { JSX } from "vue/jsx-runtime";
import { camelToKebab } from "./common"; import { camelToKebab } from "./common";
export function coerceComponent( export function coerceComponent(

View file

@ -6,14 +6,11 @@ interface CustomMatchers<R = unknown> {
toLogError(): R; toLogError(): R;
} }
declare global { declare module "vitest" {
// eslint-disable-next-line @typescript-eslint/no-namespace // eslint-disable-next-line @typescript-eslint/no-empty-interface
namespace Vi { interface Assertion extends CustomMatchers {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface // eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Assertion extends CustomMatchers {} interface AsymmetricMatchersContaining extends CustomMatchers {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface AsymmetricMatchersContaining extends CustomMatchers {}
}
} }
expect.extend({ expect.extend({

View file

@ -6,6 +6,7 @@
"strict": true, "strict": true,
"checkJs": false, "checkJs": false,
"jsx": "preserve", "jsx": "preserve",
"jsxImportSource": "vue",
"importHelpers": true, "importHelpers": true,
"moduleResolution": "node", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,