adl-lang/adl

Incorrect typescript StringMap quoting

Closed this issue · 1 comments

bacek commented

Typescript codegen doesn't quote keys in literal StringMap.

Consider this adl:

module test {

struct Test {
  StringMap<String> foo = {
    "$": "bar",
    " ": "baz"
  };
};

};

Generated code will have unquoted keys for $ and (empty string).

export function makeTest(
  input: {
    foo?: {[key: string]: string},
  }
): Test {
  return {
    foo: input.foo === undefined ? {  : "baz", $ : "bar"} : input.foo,
  };
}

Correct version should be foo: input.foo === undefined ? { " " : "baz", "$" : "bar"} : input.foo,

Fixed with b5f29eb