From c5277177c3631384617b08b28ccd172a9d19d3c9 Mon Sep 17 00:00:00 2001 From: Refringe Date: Tue, 7 Jan 2025 19:33:28 -0500 Subject: [PATCH 1/2] Type Check Before Debug This updates the npm debug command to type check before executing the run entry. If the check fails the debug will not continue. --- project/Server.code-workspace | 5 ++--- project/package.json | 4 ++-- project/tsconfig.debug.json | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 project/tsconfig.debug.json diff --git a/project/Server.code-workspace b/project/Server.code-workspace index fd11a4d51..884d36fd6 100644 --- a/project/Server.code-workspace +++ b/project/Server.code-workspace @@ -30,11 +30,10 @@ { "name": "Debug", "type": "node", - "program": "${workspaceFolder}/src/entry/run.ts", "runtimeVersion": "22.12.0", - "runtimeExecutable": "tsx", + "runtimeExecutable": "npm", "request": "launch", - "runtimeArgs": ["watch", "--clear-screen=false"], + "runtimeArgs": ["run", "run:debug"], "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "skipFiles": ["/**", "${workspaceFolder}/node_modules/**"] diff --git a/project/package.json b/project/package.json index cee6f54d8..4b652d6cd 100644 --- a/project/package.json +++ b/project/package.json @@ -14,7 +14,6 @@ "check:circular": "madge --circular --ts-config tsconfig.json --extensions ts ./src/", "lint": "npx @biomejs/biome lint ./", "lint:fix": "npx @biomejs/biome lint --write ./", - "lint:types": "tsc --noEmit", "style": "npx @biomejs/biome format ./", "style:fix": "npx @biomejs/biome format --write ./", "format": "npx @biomejs/biome check --write ./", @@ -27,8 +26,9 @@ "build:bleeding": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleeding", "build:bleedingmods": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleedingmods", "run:build": "gulp run:build", - "run:debug": "tsx ./src/entry/run.ts", + "run:debug": "npm run type-check && tsx ./src/entry/run.ts", "run:profiler": "gulp run:profiler", + "type-check": "tsc -p tsconfig.debug.json", "gen:types": "tsc -p tsconfig.types.json", "gen:docs": "typedoc --options ./typedoc.json --entryPointStrategy expand ./src", "gen:items": "tsx ./src/tools/ItemTplGenerator/ItemTplGeneratorProgram.ts", diff --git a/project/tsconfig.debug.json b/project/tsconfig.debug.json new file mode 100644 index 000000000..15cc94030 --- /dev/null +++ b/project/tsconfig.debug.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "strict": false, + "noEmit": true + }, + "exclude": ["./types/**/*"] +} From bbf56f7d23f729bcb12899b82f760d02abf60832 Mon Sep 17 00:00:00 2001 From: Refringe Date: Tue, 7 Jan 2025 19:35:37 -0500 Subject: [PATCH 2/2] Potential Type Fixes These are possible fixes for the two type errors that are currently holding back type checking this branch. I say possible because it's not tested in game and I've only solved the issues with the current types and have no idea if the types are actually correct. Needs a review. --- project/src/generators/BotGenerator.ts | 2 +- project/src/services/BotLootCacheService.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index 5be4ccf0a..d9d215f0a 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -442,7 +442,7 @@ export class BotGenerator { const chosenBodyTemplate = this.databaseService.getCustomization()[bot.Customization.Body]; // Find the body/hands mapping - const matchingBody: IWildBody = bodyGlobalDict[chosenBodyTemplate?._name]; + const matchingBody: IWildBody = bodyGlobalDict[chosenBodyTemplate?._name]?.[bot.Customization.Body]; if (matchingBody?.isNotRandom) { // Has fixed hands for this body, set them bot.Customization.Hands = matchingBody.hands; diff --git a/project/src/services/BotLootCacheService.ts b/project/src/services/BotLootCacheService.ts index dce38ed98..4fb9ebe20 100644 --- a/project/src/services/BotLootCacheService.ts +++ b/project/src/services/BotLootCacheService.ts @@ -126,7 +126,7 @@ export class BotLootCacheService { return false; }); - return this.cloner.clone(Object.fromEntries(filteredResult)); + return this.cloner.clone(Object.fromEntries(filteredResult) as Record); } return this.cloner.clone(result);