0.9.1 compiler error

Topics: General
Aug 8, 2013 at 6:15 AM
I finally bit the bullet and installed 0.9.1 (previously on 0.8). I've gone through my substantial code base and done the obvious things like swapping 'bool' for 'boolean' and removing the ? from parameters but I'm left with this error which I can't fathom out:

Error 302 All named properties must be subtypes of string indexer type 'any'. lib.d.ts 1692 5 tween loop 2.ts

I honestly have no idea what that means. It appears hundreds of times (302!). Double-click the error just takes me to the lib.d.ts file, so I'm at a complete loss.
Aug 8, 2013 at 7:00 AM
It appears after restarting Visual Studio those errors have gone and I'm just left with the massively unhelpful:

Error 1 Unable to get property 'type' of undefined or null reference D:\wamp\www\phaser\Phaser\VSTSC Phaser

No line number, not even a file telling me where to look. Literally no clue what to do now :-/
Aug 8, 2013 at 3:36 PM
Wait.. it's getting better. I've now got really helpful compiler errors like:

Error 106 Cannot convert 'number' to 'number'

Here is the offending code:

public get total(): number {
return this._frames.length;

If anyone has the slightest clue what may cause this I'd love to know :( I have literally spent several days on this now, struggling to upgrade my project to 0.9.1 and am still getting rafts of really really strange and unhelpful errors.
Aug 8, 2013 at 5:55 PM
I know I'm talking to myself now, but I've finally finally got my project compiling (with no thanks to the compilers error messages!).

I'm pretty sure I've found a bug in the compiler, but I just can't figure out where.

I have a class called Group. Inside it is a property called transform, which is of the type Phaser.Components.TransformManager:
    public transform: Phaser.Components.TransformManager;
If I compile with the type set to that above it errors with "Error 102 Unable to get property 'type' of undefined or null reference D:\wamp\www\phaser\Phaser\VSTSC Phaser" followed by 100 errors of "All named properties must be subtypes of string indexer type 'any'".

If remove the type from the property:
    public transform;
It all compiles and runs with no errors. I can compile the TransformManager quite happily, there are no errors in it and I'm using it extensively elsewhere in other classes that reference it in exactly the same way as Group does. If I add the type back in, all hell breaks lose in the compiler.

I've uploaded the complete VS project here in case anyone from MS cares: https://dl.dropboxusercontent.com/u/182996/PhaserTS091Compile.zip

You can replicate the error by opening core/Group.ts and un-commenting line 103.

A whole day wasted just boiling it down to this :(
Aug 8, 2013 at 9:16 PM
I'll try to take a look at your project.

For reference, the original error you were getting:

"All named properties must be subtypes of string indexer type 'any'."

is because of new rules around how indexers work introduced in 0.9.0. The basic idea being that type A's string indexer's return type applies a constraint on the valid return types of all other properties of type A. Consider:
interface C {
    [idx: string]: HTMLElement
    data: string;

var c: C;
var r1 = c.data;
var r2 = c['data']; // what type does this return? and is it not the same as c.data?}
Aug 8, 2013 at 9:27 PM
Thanks Dan. The first issue I posted about was throwing index issues in the actual TypeScript lib.d.ts file, not in my code. Although I'm quite sure it was something in my code causing the compiler to freak out, having 100+ errors all pointing to lib.d isn't going to help me narrow down what caused it :(
Aug 8, 2013 at 11:04 PM
Edited Aug 8, 2013 at 11:05 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

I wasn't able to narrow down the repro significantly so we might have to just step through the compiler a bit and see what's might be going wrong.