Skip to content

Commit

Permalink
Debug Type Check (#1046)
Browse files Browse the repository at this point in the history
This updates the debug command to type check before executing the run
entry. If the check fails the debug will not continue.

This unfortunately breaks the TSX `watch` function and the debugger now
has to be manually restarted when code is changed. I've been unable to
find a solution to this.

While not ideal, an alternative is to only type-check on build and leave
debug using TSX directly, like we were. Let me know if you'd rather go
that way and get your `watch` back.

----------------

Also includes possible fixes (bbf56f7)
for the two type errors that are currently holding back debug builds.

I say possible because
- I've only solved the issues with the current types and have no idea if
the types are actually correct
- Have only resolved the type errors within the IDE/TSC and have not
actually tested in game

They need to be reviewed.
  • Loading branch information
chompDev authored Jan 8, 2025
2 parents 041b419 + 162acd7 commit 929efb7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
5 changes: 2 additions & 3 deletions project/Server.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -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": ["<node_internals>/**", "${workspaceFolder}/node_modules/**"]
Expand Down
4 changes: 2 additions & 2 deletions project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion project/src/generators/BotGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion project/src/services/BotLootCacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, number>);
}

return this.cloner.clone(result);
Expand Down
8 changes: 8 additions & 0 deletions project/tsconfig.debug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"strict": false,
"noEmit": true
},
"exclude": ["./types/**/*"]
}

0 comments on commit 929efb7

Please sign in to comment.