{"action":"closed","issue":{"url":"https://api.github.com/repos/google/flatbuffers/issues/4309","repository_url":"https://api.github.com/repos/google/flatbuffers","labels_url":"https://api.github.com/repos/google/flatbuffers/issues/4309/labels{/name}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/4309/comments","events_url":"https://api.github.com/repos/google/flatbuffers/issues/4309/events","html_url":"https://github.com/google/flatbuffers/issues/4309","id":228133109,"number":4309,"title":"--ts generates incorrect vector creator static method","user":{"login":"Gozala","id":21236,"avatar_url":"https://avatars2.githubusercontent.com/u/21236?v=3","gravatar_id":"","url":"https://api.github.com/users/Gozala","html_url":"https://github.com/Gozala","followers_url":"https://api.github.com/users/Gozala/followers","following_url":"https://api.github.com/users/Gozala/following{/other_user}","gists_url":"https://api.github.com/users/Gozala/gists{/gist_id}","starred_url":"https://api.github.com/users/Gozala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gozala/subscriptions","organizations_url":"https://api.github.com/users/Gozala/orgs","repos_url":"https://api.github.com/users/Gozala/repos","events_url":"https://api.github.com/users/Gozala/events{/privacy}","received_events_url":"https://api.github.com/users/Gozala/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-05-11T21:58:17Z","updated_at":"2017-05-18T17:30:31Z","closed_at":"2017-05-18T17:30:31Z","body":"Here is an example schema:\r\n\r\n```idl\r\nnamespace Test;\r\n\r\ntable Point {\r\n  x:short;\r\n  y:short;\r\n}\r\n\r\ntable Graph {\r\n  points:[Point];\r\n}\r\n```\r\n\r\nGenerator using `--ts` generates incorrect `createPointsVector`  for the `Graph`:\r\n\r\n```ts\r\nclass Graph {\r\nstatic createPointsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset|null {\r\nif(!data){\r\n  return null;\r\n}\r\n  builder.startVector(4, data.length, 4);\r\n  for (var i = data.length - 1; i >= 0; i--) {\r\n    builder.addOffset(data[i]);\r\n  }\r\n  return builder.endVector();\r\n};\r\n// ...\r\n```\r\n\r\ntype of `data` is an array so `if (!data)` check is not necessary, most likely it meant to be a `if (data.length === 0) { return null }` instead."}}
{"actor":{"display_login":"aardappel"}}