This project is read-only.

Quoted properties problem!

Topics: General
Jul 19, 2013 at 1:29 PM
I think that ts doesn't generate correct js for quoted properties.
class Test1 {
  "prop1" = () => { alert("prop1"); };
var t = new Test1();
compiles ok, but generates incorrect code. You get runtime exception!
var Test1 = (function () {
    function Test1() {
        //********* THIS IS NOT OK MISSING []
        this."prop1" = function () {
    return Test1;
var t = new Test1();
best regards
Jul 20, 2013 at 9:50 PM
Don't use quotes in your declaration and it will be ok... as it should.

Unless you found that in reference doc and it does not work accordingly....
Jul 22, 2013 at 10:25 AM
yes in my example you could use without quotes, but if you have properties with some invalid characters it won't work.

Let say that you would like to build test framework like this:
class AccountTest {
    "Removing money from empty account should fail." = (context) => { }
    "Adding money to empty account should succeed." = (context) => { }
This should work, but ts generates invalid js code.

Jul 22, 2013 at 12:57 PM
Does the TS spec or documentation say it supports quoted property names? I don't remember seeing that anywhere.
Jul 22, 2013 at 1:24 PM
I really can't find any info in docs about this, but if this is not supported, then tsc should complain about this and not generate invalid js.

But anyway, I think that it would be nice that quoted properties will be supported.
Jul 22, 2013 at 8:31 PM
Edited Jul 22, 2013 at 8:31 PM
This should work. I've copied your original post to a work item for you