Skip to content

Conversation

@sparr
Copy link

@sparr sparr commented Nov 23, 2025

Brief Description

Currently Creep.cancelOrder (and PowerCreep) accept any string as the methodName to cancel. This can be more tightly typed as strings at are keys of methods (not data properties) in those types.

A more accurate solution would be to enumerate all of the methods that register intents.

A few new lines in the tests file include one good and one bad call to cancelOrder.

Checklists

  • Test passed
  • Coding style (indentation, etc)
  • Edits have been made to src/ files not index.d.ts
  • Run npm run compile to update index.d.ts

@ShuP1
Copy link

ShuP1 commented Nov 26, 2025

creep.cancelOrder("cancelOrder"), creep.cancelOrder("getActiveBodyparts"), creep.cancelOrder("moveTo"), ... would be valid

An explicit list (string union) might be better

@sparr
Copy link
Author

sparr commented Nov 26, 2025

Is screeps/engine's creepActions the correct list?

var creepActions = ['drop','transfer','withdraw','pickup','heal','rangedHeal','dismantle','attack','harvest','move','repair',
    'build','rangedMassAttack','rangedAttack','say','suicide','claimController','upgradeController','reserveController',
    'attackController','generateSafeMode','signController','pull'];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants