Title: Generic callback functions and 'this' · Issue #1568 · TypeScriptToLua/TypeScriptToLua · GitHub
Open Graph Title: Generic callback functions and 'this' · Issue #1568 · TypeScriptToLua/TypeScriptToLua
X Title: Generic callback functions and 'this' · Issue #1568 · TypeScriptToLua/TypeScriptToLua
Description: /** @noSelf */ declare namespace Test { export function testCallback
Open Graph Description: /** @noSelf */ declare namespace Test { export function testCallback
X Description: /** @noSelf */ declare namespace Test { export function testCallback<T extends (...args: any[]) => void>( callback: T, ): FunctionContainer<T>; } testCallback(() => {}); This fail...
Opengraph URL: https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1568
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic callback functions and 'this'","articleBody":"```\r\n/** @noSelf */\r\ndeclare namespace Test {\r\n export function testCallback\u003cT extends (...args: any[]) =\u003e void\u003e(\r\n callback: T,\r\n ): FunctionContainer\u003cT\u003e;\r\n}\r\n\r\ntestCallback(() =\u003e {});\r\n```\r\n\r\nThis fails with `error TSTL: Unable to convert function with a 'this' parameter to function 'callback' with no 'this'. To fix, wrap in an arrow function, or declare with 'this: void'.`.\r\n\r\nvalidateFunctionAssignment fails here. I could make it work by returning immediately if `toType.isTypeParameter()` is true, but I suspect that's not the correct solution to this particular problem.","author":{"url":"https://github.com/DanielAdolfsson","@type":"Person","name":"DanielAdolfsson"},"datePublished":"2024-08-04T21:23:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1568/TypeScriptToLua/issues/1568"}
| 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:379d8268-280f-1ac5-22d8-e3d4a0f60ac3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B24E:2D8AA0:3E561E:53CADD:6977D7FE |
| html-safe-nonce | 249f0932097e9af6e7f0b1956cd3f64eb4541b34b39482b6a3a329d41fcc15bb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjRFOjJEOEFBMDozRTU2MUU6NTNDQUREOjY5NzdEN0ZFIiwidmlzaXRvcl9pZCI6IjI3MTQ2MzE3MDYwODkzNDcwNzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 60549945547efb4214825bb61aed772da164fb9581aaa10b69c9060e815d7659 |
| hovercard-subject-tag | issue:2447301454 |
| 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/1568/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9790fe88ee967a5e849c55a51a7068b81660e36efc4a433338ec60704a74f4a6/TypeScriptToLua/TypeScriptToLua/issues/1568 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9790fe88ee967a5e849c55a51a7068b81660e36efc4a433338ec60704a74f4a6/TypeScriptToLua/TypeScriptToLua/issues/1568 |
| og:image:alt | /** @noSelf */ declare namespace Test { export function testCallback |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielAdolfsson |
| hostname | github.com |
| expected-hostname | github.com |
| None | b39e6c26c0326ac7510f4f58f7248053edc1a743c844376b8155c71ef8138521 |
| 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 | 9db2400e2405e5e571d97a25e1e140cfec8da1a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width