augury icon indicating copy to clipboard operation
augury copied to clipboard

Cannot see Property/State of a tuple dictionary

Open sballarati opened this issue 9 years ago • 6 comments

Augury version (required): 1.3.0 Angular version (required): 2.4.9 Date: 2017-03-10 OS: macOS Sierra 10.12.3

Code snippet:

export class Connection {
    constructor() { 
        this.groups = []; 
    }
    id: string;
    name: string;
    groups?: IConnectionGroup[]
}

export interface IConnectionGroup {
    0: string,
    1: IConnectionAttribute[]
}

export interface IConnectionAttribute {
    displayName: string;
    value: string;
    path: string;
}

in the main app
let connection : Connection = {};
let groups: IConnectionGroup['TestGroup'] = [{ displayName: "MockName", value: "Mock Value", path: "Mock path"}];
connection.groups = groups;
console.log(connection); // compare this with Property -> State, you won't see anything within groups

Description of issue: +1 I cannot see it in the properties/state panel but I am able to see the object in the chrome console, see below the groups property:

snip20170310_18

In the regular console, same groups property that was printed using console.log(): snip20170310_17

Steps to reproduce:

  1. Use the code snippet above
  2. Run the app and use console.log to print the Connection object
  3. Compare the groups property, you can see values into the browser console but you won't in Augury Property/State values

sballarati avatar Mar 17 '17 21:03 sballarati

@sballarati Can you let me know if this persists with 1.5.0 (just released)? I fixed several errors in the serialization so hopefully it was caught, but otherwise see if you can isolate it in a reproducible way for me.

stevenkampen avatar Mar 29 '17 17:03 stevenkampen

@sballarati Ahh I looked closer and realized I had assumed you were doing something much simpler. I tried a quick reproduce and was confused by how you're using this tuple type. The end result is a javascript array which is used as an object instead? I can't find an example of typescript tuples that works like this, and I couldn't get your code to compile as is. The closest I got is below. At any rate, the reason for the serialization skipping that data is that it's relatively simple logic and just plucks the elements out of an array (no searching for specially added properties).

export class Connection {
  id: string;
  name: string;
  groups?: IConnectionGroup[];
}

export interface IConnectionGroup {
  0: string;
  1: IConnectionAttribute;
}

export interface IConnectionAttribute {
  displayName: string;
  value: string;
  path: string;
}

// ...
export class TestComponent {
  connection: Connection = new Connection();
  constructor() {
    this.connection.groups = [['TestMock', {
      displayName: 'MockName',
      value: 'Mock Value',
      path: 'Mock path',
    }]];
  }
}

stevenkampen avatar Mar 31 '17 15:03 stevenkampen

Hi @stevenkampen thanks for looking into this. Unfortunately, it's not working for me with the latest version. I'll post a full sample soon so you can reproduce it easily.

Thank you, have a great weekend!

sballarati avatar Mar 31 '17 20:03 sballarati

@sballarati I understand. My previous comment articulates why it won't work, and also asks how/why you're using tuples like this, and if our logic should be expected to serialize it properly.

stevenkampen avatar Mar 31 '17 20:03 stevenkampen

@sballarati @stevenkampen It does work you just have to assign elements properly. Changing the above code as below works fine as Connection -> Group Array -> Attribute Array.

    this.connection.groups = [['hello', [{
      displayName: 'MockName',
      value: 'Mock Value',
      path: 'Mock path',
    }]]];

image

sumitarora avatar Jun 06 '17 15:06 sumitarora

Closing as above.

sumitarora avatar Jun 07 '17 14:06 sumitarora