`getObjectById` and `object.id` interfaces are untyped
See original GitHub issueCurrently all Screeps id
attributes are implemented as string
, not Id<Object>
.
Expected Behavior
It should be Id<RoomObject>
or similar type argument, so that they can be saved, and then restored:
getObjectById(id<RoomObject>) -> RoomObject?
Main point of using object ids is saving them to memory to keep a hang of any particular object for the future.
Actual Behavior
Currently all Screeps id
attributes are string
. Some objects do not have this property at all.
Your Environment
@types/screeps
version: 2.4.1 commit: ed699e3
Issue Analytics
- State:
- Created 5 years ago
- Comments:32 (30 by maintainers)
Top Results From Across the Web
how to define a type to check that an object contains an id key?
Yes, in fact you need to create a dictionary type. More info on Advanced Types. interface HasId { id: number; [key: string]: number;...
Read more >WebAssembly/DOM - Free Pascal wiki
ID is used to pass references to object between JS and Webassembly; Lifetime is controlled from WebAssembly. By using interfaces, the lifetime ...
Read more >The Definitive TypeScript 4.8 Guide - SitePen
An interface is, in essence, a named object type literal. ... getElementById that could accept either a string ID or an element, ...
Read more >TypeScript Cheatsheet, Common Errors, and More
interface FuncHolder extends Object { [index: string]: Function; } ... Lot less code! class Person { constructor (private id: number, ...
Read more >TypeScript Fundamentals - Joy of Code
Why Should You Use TypeScript? ... Type Aliases or Interfaces? ... Type Assertion Using ! Type Assertion Conversion; Literal Types; Literal Inference; Object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve merged #144 so it’s the new “current” method.
@PostCrafter @eduter @kotarou Can we all agree now that #144 is the most acceptable solution for 3.0?
It uses the
Tag
method forId<T>
and while supportingstring
ids to get game objects, officially marks them as deprecated and returnsunknown
type if not manually asserted.