Empty property name causes error

Topics: General
Sep 9, 2013 at 1:12 PM
I've been trying to find the cause of a very misleading compiler error:

"Unable to get property 'type' of undefined or null reference - VSTSC"

I took to deleting code line-by-line, and seem to have found the cause; this line:
ns[""] = attrValue;
It may look strange, but I believe it to be valid to have an empty string as a property name - in this case, I'm getting a list of XML namespaces, and this particular line is setting the default namespace in 'attrValue' to object 'ns'.

Anyway, that seems to be the cause of the error, even though the error message itself doesn't seem to relate to it.

I can get around this with:
var empty = "";
ns[empty] = attrValue
I think this may be a bug, but I thought I'd post it here first to see if others can reproduce or give a reason why it might be happening. Thanks.
Sep 9, 2013 at 1:19 PM
Just an update... the problem seems to have disappeared. I've no idea why. I was experimenting with settings an empty property name on another object, setting it to a constant, etc. with varying results until I reverted back to my original code... and now it works.

Wish I could say why.
Sep 9, 2013 at 3:36 PM
If I'm remembering right, there's a known issue about something similar. Perhaps it only happens under certain conditions. If you manage to see the breakage again, please file an issue report with the code that it fails on.
Sep 9, 2013 at 6:17 PM
I recalled the same, I see this one which matches what you're seeing: https://typescript.codeplex.com/workitem/1522, feel free to upvote it if so.
Sep 10, 2013 at 10:56 AM
I'd love to give more information, but the problem completely disappeared on me. The same line of code is now working while I was trying to figure out what might be causing it. It may well be related to the posted work item, my code looks very similar. I've upvoted it regardless.

If it reoccurs, I'll update.