typed-screeps
typed-screeps copied to clipboard
Memory is constant and therefore throws an error when trying to assign to it
https://github.com/screepers/typed-screeps/blob/ae85cfda7f488e24f1005922bb6e5de2632b0fe7/src/memory.ts#L15

Pretty self explanatory. Directly encouraged by the docs this is needed for allowing for custom serialization
No, it actually doesn't. It is trying to explain to you how access to Memory
works :)
Essentially, on first access in a tick, it will do a JSON parse of the raw memory and assign it to the variable.
If you want to do the "memory hack", you could do something like https://github.com/Jomik/screeps-ai/blob/27a5edce0ac7920f5b4feb04c3dd6808527d3509/packages/bot/src/utils/memory-hack.ts#L9
I suppose the proper keyword would be let
, but I think it is better to be very explicit if you mess with Memory
, as it can really screw you over.