Fix typechecks

This commit is contained in:
uwap 2026-01-03 09:30:08 +01:00
parent 6895b94279
commit 0176c85df4
11 changed files with 35 additions and 16 deletions

2
.gitmodules vendored
View file

@ -1,6 +1,6 @@
[submodule "deps/Traveler"] [submodule "deps/Traveler"]
path = deps/Traveler path = deps/Traveler
url = https://github.com/UndefinedCpp/Traveler.git url = https://github.com/screepers/Traveler.git
[submodule "deps/screeps-packrat"] [submodule "deps/screeps-packrat"]
path = deps/screeps-packrat path = deps/screeps-packrat
url = https://github.com/NekoKetsu/screeps-packrat.git url = https://github.com/NekoKetsu/screeps-packrat.git

2
deps/Traveler vendored

@ -1 +1 @@
Subproject commit c65bb420704cf027161405d7edfbc06f7298494e Subproject commit 2fd1c0ce32ec214b93871ad4d780fd3952c8bbff

View file

@ -6,7 +6,7 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "npx rspack build", "build": "npx rspack build",
"lint": "npx eslint src/", "lint": "npx tsc --noEmit && npx eslint src/",
"test": "jest --passWithNoTests", "test": "jest --passWithNoTests",
"push": "yarn build && node ./upload.js" "push": "yarn build && node ./upload.js"
}, },
@ -23,6 +23,7 @@
"@swc/core": "^1.15.5", "@swc/core": "^1.15.5",
"@swc/jest": "^0.2.39", "@swc/jest": "^0.2.39",
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/lodash": "3.10.2",
"@types/node": "^25.0.3", "@types/node": "^25.0.3",
"@types/screeps-profiler": "^1.2.6", "@types/screeps-profiler": "^1.2.6",
"@typescript-eslint/eslint-plugin": "^8.50.0", "@typescript-eslint/eslint-plugin": "^8.50.0",

View file

@ -222,7 +222,7 @@ export default profiler.registerFN(function (room: Room) {
for (let i = 0; i < path.length; i++) { for (let i = 0; i < path.length; i++) {
const pos = path[i]; const pos = path[i];
structures[getCoord(pos.x, pos.y)] structures[getCoord(pos.x, pos.y)]
= (i === path.length - 1 && "energy" in target) = (i === path.length - 1 && "ticksToRegeneration" in target)
? STRUCTURE_CONTAINER ? STRUCTURE_CONTAINER
: STRUCTURE_ROAD; : STRUCTURE_ROAD;
} }

View file

@ -26,6 +26,10 @@ export const runRepair = profiler.registerFN(
return TaskStatus.DONE; return TaskStatus.DONE;
} }
if (target != null && target.hits >= target.hitsMax) {
return TaskStatus.DONE;
}
if (target == null if (target == null
|| creep.repair(target) === ERR_NOT_IN_RANGE) { || creep.repair(target) === ERR_NOT_IN_RANGE) {
creep.travelTo(task.targetPos); creep.travelTo(task.targetPos);

View file

@ -23,8 +23,10 @@ const assignTask = (creep: Creep) => {
} }
if (creep.room.controller != null) { if (creep.room.controller != null) {
if (creep.room.controller.ticksToDowngrade > 1000) { if (creep.room.controller.ticksToDowngrade > 1000) {
const urgentRepair = creep.pos.findClosestByRange(FIND_MY_STRUCTURES, { const urgentRepair = creep.pos.findClosestByRange(FIND_STRUCTURES, {
filter: s => s.hits < s.hitsMax * 0.3, filter: s => s.hits < s.hitsMax * 0.3 && ("my" in s
? s.my
: s.structureType === STRUCTURE_CONTAINER),
}); });
if (urgentRepair != null) { if (urgentRepair != null) {
return Tasks.Repair(urgentRepair); return Tasks.Repair(urgentRepair);

View file

@ -21,10 +21,10 @@ const assignTask = (creep: Creep) => {
} }
else { else {
const urgentRepair = creep.pos.findClosestByRange(FIND_STRUCTURES, { const urgentRepair = creep.pos.findClosestByRange(FIND_STRUCTURES, {
filter: s => "my" in s filter: s => ("my" in s
? s.my ? s.my
: s.structureType === STRUCTURE_CONTAINER : s.structureType === STRUCTURE_CONTAINER)
&& s.hits < s.hitsMax * 0.3, && s.hits < s.hitsMax * 0.3,
}); });
if (urgentRepair != null) { if (urgentRepair != null) {
return Tasks.Repair(urgentRepair); return Tasks.Repair(urgentRepair);

View file

@ -1,11 +1,13 @@
import "../deps/Traveler/Traveler.js";
import "../deps/Traveler/index.d.ts";
import "./Proto";
import profiler from "screeps-profiler";
import { Clerk } from "./Workers/Clerk"; import { Clerk } from "./Workers/Clerk";
import { Constructor } from "./Workers/Constructor"; import { Constructor } from "./Workers/Constructor";
import { Miner } from "./Workers/Miner"; import { Miner } from "./Workers/Miner";
import { Upgrader } from "./Workers/Upgrader"; import { Upgrader } from "./Workers/Upgrader";
import { runWorkers, spawnWorkers } from "./Workers/worker"; import { runWorkers, spawnWorkers } from "./Workers/worker";
import "../deps/Traveler/Traveler";
import profiler from "screeps-profiler";
import "./Proto";
import RoomPlanner from "./RoomPlanner"; import RoomPlanner from "./RoomPlanner";
const runTowers = profiler.registerFN((spawn: StructureSpawn) => { const runTowers = profiler.registerFN((spawn: StructureSpawn) => {

3
src/types.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
import lodash from "lodash";
declare const _ = typeof lodash;

View file

@ -23,10 +23,12 @@
}, },
"include": [ "include": [
"next-env.d.ts", "next-env.d.ts",
"**/*.ts", "src/**/*.ts",
"**/*.tsx" "src/**/*.tsx",
], ],
"exclude": [ "exclude": [
"node_modules" "node_modules",
"deps",
"dist",
] ]
} }

View file

@ -1447,6 +1447,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
"@types/lodash@3.10.2":
version "3.10.2"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-3.10.2.tgz#c1fbda1562ef5603c8192fe1fe65b017849d5873"
integrity sha512-TmlYodTNhMzVzv3CK/9sXGzh31jWsRKHE3faczhVgYFCdXIRQRCOPD+0NDlR+SvJlCj914yP3q3aAupt53p2Ug==
"@types/mime@^1": "@types/mime@^1":
version "1.3.5" version "1.3.5"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690"