Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object for defining globals #79

Open
dmarcuse opened this issue Dec 6, 2016 · 2 comments
Open

Object for defining globals #79

dmarcuse opened this issue Dec 6, 2016 · 2 comments

Comments

@dmarcuse
Copy link

dmarcuse commented Dec 6, 2016

In screeps, there's an object global which can be used to store values globally (i.e. for use from the console). It should be as simple as adding a declare var global:any; in the code, but I'm not sure where it should be put (hence an issue instead of a PR)

@Dessix
Copy link
Collaborator

Dessix commented Feb 6, 2017

It would likely be more helpful to store a type for global with an interface that promotes extensibility. Importantly, class types will cancel those from .d.ts files out under certain circumstances, so this must be done carefully. I recommend following the extensibility model put forth under #72 for classes, with the interface methodology allowing new information to be added without overwriting the existing ones. A similar model can be used for memory customization, with the added benefit that the user can further constrain the types by redeclaring the interface with a more precise interface later.

@bryanbecker
Copy link
Member

bryanbecker commented May 15, 2017

global should not be typed by this project. It's unrelated to the Screeps code base, and will only make it more of a pain for users to integrate their own typings.

The global object that currently exists in Screeps is from Node. If you want it typed, you can add it's typings with typings install --save --global "[email protected]", and then extend it in your own code with:

declare namespace NodeJS {
  export interface Global {
     // whatever you want to add
  }
}

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

No branches or pull requests

3 participants