Title: Declaring generic type of implicitly called method · Issue #15877 · microsoft/TypeScript · GitHub
Open Graph Title: Declaring generic type of implicitly called method · Issue #15877 · microsoft/TypeScript
X Title: Declaring generic type of implicitly called method · Issue #15877 · microsoft/TypeScript
Description: This is a feature request. I am unaware of any recent similar requests For typing purposes and simple code, it would be good to be able to declare generics of implicitly called methods. TypeScript Version: Any under 2.3.x at time of writ...
Open Graph Description: This is a feature request. I am unaware of any recent similar requests For typing purposes and simple code, it would be good to be able to declare generics of implicitly called methods. TypeScript ...
X Description: This is a feature request. I am unaware of any recent similar requests For typing purposes and simple code, it would be good to be able to declare generics of implicitly called methods. TypeScript ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/15877
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Declaring generic type of implicitly called method ","articleBody":"This is a feature request. I am unaware of any recent similar requests\r\nFor typing purposes and simple code, it would be good to be able to declare generics of implicitly called methods.\r\n\r\n**TypeScript Version:** Any under 2.3.x at time of writing\r\n\r\n**Code Example**\r\nTake the following method\r\n```typescript\r\nmyImplicitlyCalledMethod = \u003cT>(someVar: any): T => {\r\n let b:T;\r\n //Code that converts someVar to T or create an object with type T from someVar\r\n return b;\r\n}\r\n```\r\n**Actual behavior:**\r\nRight now when you call a method with a generic type implicitly, you cannot declare the type directly.\r\nThe following code is what I have to do to get the type, along with an implicit call of the method.\r\n```typescript\r\nmyCallingMethodWithoutTyping = (someVar:any) => this.myImplicitlyCalledMethod;\r\nmyCallingMethodWithTyping = (someVar:any) => this.myImplicitlyCalledMethod\u003cnumber>(someVar);\r\n```\r\n**Expected behavior:**\r\nThis is what I would like to be able to do :\r\n```typescript\r\nmyCallingMethodWithoutTyping = (someVar:any) => this.myImplicitlyCalledMethod\u003cnumber>;\r\n```\r\nThe code however throws an exception while compiling as it expects you to pass the parameter when you declare the type of the generic.\r\n\r\n**Language feature checklist**\r\n* Syntactic: Allow declaring of generics in implicitly called methods\r\n* Semantic: Should not change the core logic of typescript, or anything.\r\n* Emit: Emitted code would not change, it would simply be to help with declaring types with less code.\r\n* Compatibility: Code using this wouldn't be backwards compatible.\r\n* Other:\r\n * Performance: This might affect performance depending on how it's implemented.\r\n * Tooling: Would actually help with inferred typing\r\n","author":{"url":"https://github.com/chpoit","@type":"Person","name":"chpoit"},"datePublished":"2017-05-16T13:46:22Z","url":"https://github.com/microsoft/TypeScript/issues/15877"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:2f7e6b89-ce8a-b90c-59a3-f3e5f2270594 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B3E4:14ECB:5FDD43:7BCA32:6B00DE1A |
| html-safe-nonce | 974173935e55cf18bf7f395211fa84de01c7f39467b7b76012907b3b58683aba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0U0OjE0RUNCOjVGREQ0Mzo3QkNBMzI6NkIwMERFMUEiLCJ2aXNpdG9yX2lkIjoiNTA1MTYxMjEyMDEyMzIzNTg2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4a0ba4319e5cac4886a63c51c70253c28170e6fcbc62a738f415c3b9dc5a3ed5 |
| hovercard-subject-tag | issue:229039269 |
| 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/15877/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0ab852beca9304e1a3d348129e0517dc3905ba69661f9521257ae3daf7860c36/microsoft/TypeScript/issues/15877 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0ab852beca9304e1a3d348129e0517dc3905ba69661f9521257ae3daf7860c36/microsoft/TypeScript/issues/15877 |
| og:image:alt | This is a feature request. I am unaware of any recent similar requests For typing purposes and simple code, it would be good to be able to declare generics of implicitly called methods. TypeScript ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chpoit |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width