Screeps d.ts file and gulp script



  • Here is the Gist

    I don't know if there are any people interested in typescript here but I thought I would share the first version of my screeps.d.ts file, I've also included a gulpfile that will compile and upload your script to the 'dev' branch. You need to a 'secrets.js' file in the same directory that exports an object with 'email' and 'password' for you screeps account. Remember to NOT include secrets.js in your git repo. I recommend using microsofts new Visual Studio Code for editing with support for typescript intellisense and gulp integration.

    Requirements to build:
    node and npm
    gulp
    gulp-typescript
    tsd(for lodash typings)

    I'm sure there are lots of improvements that could be made, this is my first shot at a d.ts file and I didn't try to make the game objects extendable.

    I also kinda just gave up on documenting halfway through, yeah sorry :P.



  • Haha woops i suppose i should have actually linked it. Here you go



  • Thank you. Will test the d.ts file.



  • Thank you for your work on this. I'm new to typescript, and it seems to solve what I've always hated about javascript. What is the correct way to extend your interface? For example, I want CreepMemory to havea property for role. I could easilly modify the d.ts file you've provided, which works great but feels wrong.
    This is what feels right, but I'm trying to avoid starting a bad habbit when learning something new.
    `
    interface DewCreepMemory extends CreepMemory{
    role:string;
    }
    interface DewCreep extends Creep{
    memory:DewCreepMemory;
    }

    class BaseCreep{
    work(creep:DewCreep){
    creep.memory.role
    }
    }
    `



  • Ok, I figured it out.
    http://www.typescriptlang.org/Handbook#declaration-merging
    So

    interface CreepMemory{
    role:string;
    }

    will just merge it with whatever is in yours.