Title: NewableFunction not working as intended · Issue #44337 · microsoft/TypeScript · GitHub
Open Graph Title: NewableFunction not working as intended · Issue #44337 · microsoft/TypeScript
X Title: NewableFunction not working as intended · Issue #44337 · microsoft/TypeScript
Description: There is little info about NewableFunction except for the meeting notes in #27102 and the pr #27028. As far as I understand the comments there, a NewableFunction should be "callable" with new Foo(...), right? Or do we have to stick with ...
Open Graph Description: There is little info about NewableFunction except for the meeting notes in #27102 and the pr #27028. As far as I understand the comments there, a NewableFunction should be "callable" with new Foo(....
X Description: There is little info about NewableFunction except for the meeting notes in #27102 and the pr #27028. As far as I understand the comments there, a NewableFunction should be "callable" with...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/44337
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NewableFunction not working as intended","articleBody":"There is little info about `NewableFunction` except for the meeting notes in #27102 and the pr #27028.\r\n\r\nAs far as I understand the comments there, **a `NewableFunction` should be \"callable\" with `new Foo(...)`, right?** Or do we have to stick with `apply(...)`/`call(...)`?\r\n\r\nExample:\r\n\r\n```typescript\r\nclass Foo {}\r\n\r\nfunction doSomething(clazz: NewableFunction) {\r\n new clazz();\r\n // This expression is not constructable.\r\n // Type 'NewableFunction' has no construct signatures\r\n}\r\n\r\n\r\n\r\ndoSomething(Foo); // passes but would fail with \"normal functions\" aka. CallableFunction\r\n```\r\n\r\n\r\n**Question about workaround:**\r\n\r\nIf `NewableFunction` works as desired should we stick with `new Function.prototype.bind.call(clazz, undefined);` or should we define our own \"`ConstructableFunction`\" (a lot of people suggest this and [even angular did it](https://github.com/angular/angular/blob/6.1.6/packages/core/src/type.ts#L25)):\r\n\r\neg.\r\n\r\n```typescript\r\nexport interface ConstructableFunction extends NewableFunction {\r\n new(...args: any[]): any\r\n}\r\n```\r\n\r\n","author":{"url":"https://github.com/rajmondx","@type":"Person","name":"rajmondx"},"datePublished":"2021-05-30T04:11:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/44337/TypeScript/issues/44337"}
| 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:575c2747-f5a9-8c0b-7643-c61c71126664 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCBC:2B1AA3:1BF2FF:266943:6A616D4B |
| html-safe-nonce | d289a0ca8ed78fda8adf2fef1d937e3ee1e849819ce4d8ee1230956c3dfca8c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0JDOjJCMUFBMzoxQkYyRkY6MjY2OTQzOjZBNjE2RDRCIiwidmlzaXRvcl9pZCI6IjMzOTk1MzYyMDc5MjM4NjY5NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b74ead086058f88d38236ac0aa524951742917c64866957d6389e1b7708b9177 |
| hovercard-subject-tag | issue:906622985 |
| 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/microsoft/TypeScript/44337/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1ac42e0104135cc1bcef1a3e98b0ce11901bff7026d0f9f8d0ac87a925ce45f3/microsoft/TypeScript/issues/44337 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1ac42e0104135cc1bcef1a3e98b0ce11901bff7026d0f9f8d0ac87a925ce45f3/microsoft/TypeScript/issues/44337 |
| og:image:alt | There is little info about NewableFunction except for the meeting notes in #27102 and the pr #27028. As far as I understand the comments there, a NewableFunction should be "callable" with new Foo(.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rajmondx |
| hostname | github.com |
| expected-hostname | github.com |
| None | a69385f7d268ece7ad25b131bbd70f457024811fc79afcae43785a6849b724e2 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| 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 | 484cf265a1f970d5c7a5e7c37cb677d8010aa12f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width