Title: Array indexing does not get +1 in transpiled output in a rather specific scenario with optional chaining · Issue #1605 · TypeScriptToLua/TypeScriptToLua · GitHub
Open Graph Title: Array indexing does not get +1 in transpiled output in a rather specific scenario with optional chaining · Issue #1605 · TypeScriptToLua/TypeScriptToLua
X Title: Array indexing does not get +1 in transpiled output in a rather specific scenario with optional chaining · Issue #1605 · TypeScriptToLua/TypeScriptToLua
Description: When all: Foo is an interface from extending Array or ReadonlyArray An object bar has a property with type Foo | undefined Optional chaining used to array-index Foo ...after a property access to bar Then, the transpiled lua does not get ...
Open Graph Description: When all: Foo is an interface from extending Array or ReadonlyArray An object bar has a property with type Foo | undefined Optional chaining used to array-index Foo ...after a property access to ba...
X Description: When all: Foo is an interface from extending Array or ReadonlyArray An object bar has a property with type Foo | undefined Optional chaining used to array-index Foo ...after a property access to ba...
Opengraph URL: https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1605
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Array indexing does not get +1 in transpiled output in a rather specific scenario with optional chaining","articleBody":"When all:\r\n- `Foo` is an interface from extending `Array` or `ReadonlyArray`\r\n- An object `bar` has a property with type Foo | undefined\r\n- Optional chaining used to array-index `Foo`\r\n- ..._after_ a property access to `bar`\r\n\r\nThen, the transpiled lua does not get +1 on the array indexing.\r\n\r\n```ts\r\ninterface Foo extends Array\u003cnumber\u003e {}\r\nconst b: {arr?: Foo} = {arr:[1,2]}\r\n\r\n// incorrectly prints 1\r\nprint(b.arr?.[1])\r\n\r\nconst arr: Foo | undefined = b.arr\r\nprint(arr?.[1])\r\n\r\n// all correctly prints 2\r\nprint(b.arr![1])\r\n\r\nconst arr2 : Foo | undefined = [1,2]\r\nprint(arr2?.[1])\r\n\r\nconst c: {arr?: number[]} = {arr:[1,2]}\r\nprint(c.arr?.[1])\r\n\r\nconst d: {arr: Foo} = {arr:[1,2]}\r\nprint(c.arr?.[1])\r\n```\r\nTSTL v1.28.1\r\n\r\nI'm amazed and annoyed how many stars had to align to encounter this bug, and that it can't be more miminal.\r\n\r\n","author":{"url":"https://github.com/GlassBricks","@type":"Person","name":"GlassBricks"},"datePublished":"2024-12-07T01:26:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1605/TypeScriptToLua/issues/1605"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d6d05cd7-0540-ede1-5fda-2c3053f89e14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 952C:25FEC4:2BDB7D:3B54D2:6973510C |
| html-safe-nonce | d213a8efc3199c17c9a3062c2cdb2284ef61239bf3f56544d79e68ff52a73c40 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTJDOjI1RkVDNDoyQkRCN0Q6M0I1NEQyOjY5NzM1MTBDIiwidmlzaXRvcl9pZCI6IjIxOTE5MDM3MzA1NTI3NTQ0NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c11bea926bc7f8c15c67b38d5e6c6886afca10f231e20d8e4d18bae2ea9183f6 |
| hovercard-subject-tag | issue:2724235407 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/TypeScriptToLua/TypeScriptToLua/1605/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c3423f5e260f9f41064d78eca6f1ac5466ab1d977dc580da7c58673fe2cd655/TypeScriptToLua/TypeScriptToLua/issues/1605 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c3423f5e260f9f41064d78eca6f1ac5466ab1d977dc580da7c58673fe2cd655/TypeScriptToLua/TypeScriptToLua/issues/1605 |
| og:image:alt | When all: Foo is an interface from extending Array or ReadonlyArray An object bar has a property with type Foo | undefined Optional chaining used to array-index Foo ...after a property access to ba... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GlassBricks |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9c6b49fea3d431063963fbeee3309a15cb4096903286e532f663096b47b63bc6 |
| turbo-cache-control | no-preview |
| go-import | github.com/TypeScriptToLua/TypeScriptToLua git https://github.com/TypeScriptToLua/TypeScriptToLua.git |
| octolytics-dimension-user_id | 44121206 |
| octolytics-dimension-user_login | TypeScriptToLua |
| octolytics-dimension-repository_id | 115876595 |
| octolytics-dimension-repository_nwo | TypeScriptToLua/TypeScriptToLua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 115876595 |
| octolytics-dimension-repository_network_root_nwo | TypeScriptToLua/TypeScriptToLua |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 814e1d7d82db0f7eb6982bfa0395502441bb14ad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width