-
Notifications
You must be signed in to change notification settings - Fork 5
How do you extend prototypes as suggested in globalBootStrap()? #9
Comments
I can comment on this tomorrow. |
Although, Typescript classes and inheritance are compiled to JavaScript prototypes, you can't easily extend Screeps' object prototypes, because interface doesn't allow it.
Drawback for this is that if "screeps-typescript-declarations" project is updated then you would have to merge the changes manually to your project. Which is quite inconvenient.
For example:
Sad part for this solution is that it's not very pro JavaScript. JS is popular by its prototypes and unfortunately we're going more "Java" like. It's not supposed to be like that.
I linked this issue to GitHub page and also asked opinion from some people in IRC. |
It seems like TS compiler knows to merge different ambient module, so all we have to do is declaring an interface Creep in a .d.ts file, containing all the new function that we're extending the prototype with |
This seems to work well, NhanHo. Thanks. I'll close this issue. Feel free to reopen it if there's something to add. |
This suggests that interfaces can't be extended.
The text was updated successfully, but these errors were encountered: