Title: Naked generic type returned from iterator method · Issue #59161 · microsoft/TypeScript · GitHub
Open Graph Title: Naked generic type returned from iterator method · Issue #59161 · microsoft/TypeScript
X Title: Naked generic type returned from iterator method · Issue #59161 · microsoft/TypeScript
Description: 🔎 Search Terms generic generator static 🕗 Version & Regression Information I was unable to test this on prior versions because there is still no online version of every-ts bisect ⏯ Playground Link Link 💻 Code class Base { static *[Symbol...
Open Graph Description: 🔎 Search Terms generic generator static 🕗 Version & Regression Information I was unable to test this on prior versions because there is still no online version of every-ts bisect ⏯ Playground Link ...
X Description: 🔎 Search Terms generic generator static 🕗 Version & Regression Information I was unable to test this on prior versions because there is still no online version of every-ts bisect ⏯ Playground L...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/59161
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Naked generic type returned from iterator method","articleBody":"### 🔎 Search Terms\r\n\r\ngeneric generator static\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- I was unable to test this on prior versions because there is still no online version of every-ts bisect\r\n\r\n### ⏯ Playground Link\r\n\r\n[Link](https://www.typescriptlang.org/play/?#code/N4KABBYMYDYIYGcFgEKIKZlJHYEBc58BLKMAKgG0BlATwFsAjAexgDpj90AnI57gLoAeACoA+ABT4AFsQQAuMCICUWcLg21i6GABMwMuQG51GgL6mwFnLETIAwrL1h0ADy4A7XcjQJMwa0goZg8CA3QwgF4wADMAVw8oEhDyMAlVYDAtHV1Ux2JnMxMbELCANzgYOMxoyjZ6rgJ0gUoABgEjMAB6LqVLYNDWdDYYZgBzCQqq9GVOnrB8vRALEGwg+CRUDDUNCAIiUljmZlFJQwUlDMtdsG50fDjuDwNZBGLdwIhP6A2HJ303J5vFs-FhvgNypVqmBootdGwYsd0nNenD+qUhiNxpMoTMUQt-ssgA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\nclass Base {\r\n static *[Symbol.iterator]\u003cT>(this: T) {\r\n yield this;\r\n }\r\n}\r\nclass Child extends Base {}\r\nconst test = function* () { yield* Child };\r\nconst value = [...test()][0]; // T\r\nconsole.log(value); // Child\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\nThe result is typed as T, whatever generic parameter outside of generic code means.\r\n\r\n### 🙂 Expected behavior\r\n\r\nT should be instantiated with Child during a call to `[Symbol.iterator]`\r\n\r\n### Additional information about the issue\r\n\r\nFor regular static method calls it works as expected, by instantiating T\r\n\r\n```ts\r\nclass Base {\r\n static foo\u003cT>(this: T) {\r\n return this;\r\n }\r\n}\r\nclass Child extends Base {}\r\nconst value = Child.foo(); // Child\r\nconsole.log(value); // Child\r\n```\r\n\r\nOn the other hand, this is a nice way to create unique types for opaque type implementation! 🙃","author":{"url":"https://github.com/reverofevil","@type":"Person","name":"reverofevil"},"datePublished":"2024-07-07T01:58:37Z","url":"https://github.com/microsoft/TypeScript/issues/59161"}
| 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:7ba7cc69-82a3-f38a-134c-753b23274452 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 805C:76F02:2C04461:3849AE0:6B01ADF2 |
| html-safe-nonce | 19fdda22608295ca69ae6a9b41c15723cfa0a1c3c918a668c3d75fae3e01cbe0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDVDOjc2RjAyOjJDMDQ0NjE6Mzg0OUFFMDo2QjAxQURGMiIsInZpc2l0b3JfaWQiOiIzNDQ1ODQ2ODI1OTQ3NDc1NDQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c3cdba8844f3fdb51ba223c6e91157203289c10f19dcf6d624dea690c0074a64 |
| hovercard-subject-tag | issue:2393848465 |
| 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/59161/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a347e4ea7caf96c3dab93bbac21ebe30f5cc87201b330a6d07cc986f43a04c8/microsoft/TypeScript/issues/59161 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a347e4ea7caf96c3dab93bbac21ebe30f5cc87201b330a6d07cc986f43a04c8/microsoft/TypeScript/issues/59161 |
| og:image:alt | 🔎 Search Terms generic generator static 🕗 Version & Regression Information I was unable to test this on prior versions because there is still no online version of every-ts bisect ⏯ Playground Link ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | reverofevil |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width