question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`getObjectById` and `object.id` interfaces are untyped

See original GitHub issue

Currently 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:closed
  • Created 5 years ago
  • Comments:32 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
pyrodoggcommented, Nov 20, 2019

I’ve merged #144 so it’s the new “current” method.

1reaction
pyrodoggcommented, Nov 18, 2019

@PostCrafter @eduter @kotarou Can we all agree now that #144 is the most acceptable solution for 3.0?

It uses the Tag method for Id<T> and while supporting string ids to get game objects, officially marks them as deprecated and returns unknown type if not manually asserted.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found