Quoted Property issue

Topics: General
Oct 18, 2013 at 11:33 PM
Edited Oct 18, 2013 at 11:35 PM
I am trying to use a method in an existing property but I can't seem to make the proper class for it. This is the JS

var msnry = new Masonry(container, {
    // options
    columnWidth: 350,
    itemSelector: '.item',
    "isFitWidth": true
But I don't know how to make a class that would support the "isFitWidth" property. I tried

class Masonry{
columnWidth: any;
itemSelector: any;
"isFitWidth": any;
constructor(s: any, t: Masonry){}

But it doesn't work. I am very new so sorry if this is a ridiculous question. Thank you to anyone that can help me understand how to do this
Oct 18, 2013 at 11:44 PM
You're doing it correctly. The latest TypeScript release has a bug that's making accessing the quoted property name an error when it shouldn't be. As a workaround you can use index notation. With the latest bits in the develop branch this all works correctly though:
class Masonry {
    columnWidth: number;
    itemSelector: any;
    "isFitWidth": boolean;
    constructor(s: any, t: Masonry) { }

var c = new Masonry(1, null);
var r = c.isFitWidth; // r is type boolean
var r2 = c['isFitWidth']; // r2 is type Boolean