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

helpers.ts LookAtResultMatrix interface #14

Open
Strategic-Link-Consulting opened this issue Apr 6, 2016 · 4 comments
Open

helpers.ts LookAtResultMatrix interface #14

Strategic-Link-Consulting opened this issue Apr 6, 2016 · 4 comments

Comments

@Strategic-Link-Consulting

Think it should be declared as a string for named array, compiler was balking til I changed it.

interface LookAtResultMatrix {
    [coord: string]: LookAtResultMatrix|LookAtResult[]
}
@NhanHo
Copy link
Collaborator

NhanHo commented Apr 19, 2016

Hi, Sorry for the late reply.

Can you give me an example of code that the compiler will complain with coord being number? Looking at the screeps docs (http://support.screeps.com/hc/en-us/articles/203079011-Room#lookForAtArea), the result is a 2d array with both indices being number. I'm not sure which usage will cause a compile time error?

@dunkndonuts
Copy link

Error is src\Prototypes\RoomPosition.ts(37,24): error TS2345: Argument of type 'LookAtResultMatrix | LookAtResult[] | LookAtResult' is not assignable to parameter of type 'Dictionary'.
Type 'LookAtResultMatrix' is not assignable to type 'Dictionary'.
Index signature is missing in type 'LookAtResultMatrix'.

    for (var rowPos in area) {
        for (var colPos in area[rowPos]) {
            var items = area[rowPos][colPos];
            if(!_.some(items, (lookAt: LookAtResult ) => 
                    lookAt.type === "constructionSite"
                    || lookAt.type === "exit" 
                    || lookAt.type === "source"
                    || lookAt.type === "structure"
                    || (ignoreCreeps ? false : lookAt.type === "creep")
                    || (lookAt.type === "terrain" && lookAt.terrain === "wall"))) {
                var checkPos: RoomPosition = room.getPositionAt(Number(colPos), Number(rowPos));
                room.createFlag(checkPos.x, checkPos.y, undefined, COLOR_YELLOW, COLOR_YELLOW).toString();
                routableTiles[checkPos.getId()] = checkPos;
            }
        }
    }

@NhanHo
Copy link
Collaborator

NhanHo commented Apr 21, 2016

@dunkndonuts : That code compiles normal for me. And I can't figure out how to reproduce the problem still. Any chance you can get a simple snippet for it?

@rogerreeder
Copy link

rogerreeder commented May 18, 2016

I adjusted my code to
if(!_.some(area[<string>rowPos][colPos], (lookAt: LookAtResult ) =>
The compiler liked that.

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

4 participants