Title: Design Meeting Notes, 4/30/2024 · Issue #58417 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 4/30/2024 · Issue #58417 · microsoft/TypeScript
X Title: Design Meeting Notes, 4/30/2024 · Issue #58417 · microsoft/TypeScript
Description: TReturn and TYield for Iterators and Other Types #58243 TReturn is the type of values returned by a generator. TYield is the type of values yielded by a generator. When we added these, we only added them to certain types like IteratorRes...
Open Graph Description: TReturn and TYield for Iterators and Other Types #58243 TReturn is the type of values returned by a generator. TYield is the type of values yielded by a generator. When we added these, we only adde...
X Description: TReturn and TYield for Iterators and Other Types #58243 TReturn is the type of values returned by a generator. TYield is the type of values yielded by a generator. When we added these, we only adde...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/58417
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 4/30/2024","articleBody":"\r\n# `TReturn` and `TYield` for Iterators and Other Types\r\n\r\n#58243\r\n\r\n* `TReturn` is the type of values *returned* by a generator.\r\n* `TYield` is the type of values *yielded* by a generator.\r\n* When we added these, we only added them to certain types like `IteratorResult`\r\n * Since then, we have a PR that adds type parameters to `Iterator`, `IterableIterator`, `AsyncIterable`, etc.\r\n * What this has meant since then was that if you ever try to grab `value` off of most `IteratorResult`s, then you'll get `any`.\r\n * Good as a fall-back, but usually not what people want.\r\n* Changing this is a breaking change - so how can we avoid breaks?\r\n * First, each of these types should have a default value for `TReturn` and `TYield` that is `any`.\r\n * But when a user writes `Iterator\u003cnumber\u003e`, TypeScript should preserve that type as-is.\r\n * What is the level of breakage as is?\r\n * Almost every case is an example of the type system not knowing that `size \u003e 0` implies `value` is not `undefined`.\r\n * There's also a lot of breakage around DefinitelyTyped's `ExpectType` and `ExpectError` utility types.\r\n* Several new errors introduced. Previously, people expecting `.next()` to return a `T` now get `T | void`.\r\n * e.g. `if (something.size === 1) { something.values().nexT().value.getTasks(); }`\r\n * Why is it `void` and not `undefined`?\r\n * Should it be `undefined`?\r\n * We really don't want to relitigate all the issues around non-returning functions returning `void` instead of `undefined`.\r\n * It's possible we carve things out for generators.\r\n * Should we allow postfix `!` to get rid of `void`?\r\n* How many upvotes does resolution for this issue have?\r\n * Old issue had around 15 upvotes.\r\n * This is so breaky that most of this has to go under a switch.\r\n* What happens if we don't do this?\r\n * People trying to thread these into the built-in iterator types.\r\n * If you have a generator, you can now write `myGenerator().map(x =\u003e x * x)` and you want the `TReturn` preserved.\r\n* If the worst thing you have to do is add a `!`, is that so bad?\r\n* Feel like there should be an approach where this is flagged.\r\n * Could be like `strictBindCallApply`.\r\n * We fret about breaks for much more widely-requested features.\r\n * But the people it breaks are using iterators, probably want to use the feature.\r\n * The flag that this conceptually aligns with is `noUncheckedIndexedAccess`.\r\n * Ah yes, `.next()`, the famous indexed access syntax.\r\n * Okay, fine, a separate flag with an equally bad name (`noUncheckedIteratorAccess` or `noUncheckedIteratorResult`).\r\n\r\n# `tsc --init` Updates?\r\n\r\n* We noticed `tsc --init` adds `\"module\": \"commonjs\"` - which our docs said to never ever ever do.\r\n* Okay, what else do we need to fix in `--init`?\r\n* [Ryan asked on Twitter what people would like to change](https://twitter.com/SeaRyanC/status/1782783901213282557).\r\n* People said lots of stuff\r\n * Big one that resonates: remove the wall of text comments\r\n* Are we okay wiht `tsc --init` generating a file today?\r\n * Uh yes.\r\n* Okay, that's a good start.\r\n* What else?\r\n * Make it minimal\r\n * People seem opposed to interactive.\r\n* Okay, what are things that need to be hashed through?\r\n * `target: esnext`?\r\n * `module` - `node16` or `bundler`?\r\n * `verbatimModuleSyntax`?\r\n * `skipLibCheck`?\r\n * We need to hash through these.\r\n* Should we still have *some* comments on defaults?\r\n * Maybe.\r\n * [Ryan also wrote a wizard](https://ryancavanaugh.github.io/tsc-init/), someone else wrote something too.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2024-05-02T22:14:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/58417/TypeScript/issues/58417"}
| 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:b13b1487-b4b5-891b-008d-b3dcb0d404f6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC9A:18D9A8:2E6FBE5:42068C4:6A4CFFC5 |
| html-safe-nonce | dba3de51d2d19fdf6a473d6d7ed8432454c0c9eb772e13f74734c92d08d90a4f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzlBOjE4RDlBODoyRTZGQkU1OjQyMDY4QzQ6NkE0Q0ZGQzUiLCJ2aXNpdG9yX2lkIjoiNTI5NzUwNjYxMTY1NTQ3NDYxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b0f0732ed6e0abf0f553e07f1cd8f889469854cc3ab577049344112821118efd |
| hovercard-subject-tag | issue:2276592854 |
| 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/58417/issue_layout |
| twitter:image | https://opengraph.githubassets.com/74eca7b1f4a0483ae7dfee9fef6603cf8adaf03fdf9ed6c4ba1e04523a773bcd/microsoft/TypeScript/issues/58417 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/74eca7b1f4a0483ae7dfee9fef6603cf8adaf03fdf9ed6c4ba1e04523a773bcd/microsoft/TypeScript/issues/58417 |
| og:image:alt | TReturn and TYield for Iterators and Other Types #58243 TReturn is the type of values returned by a generator. TYield is the type of values yielded by a generator. When we added these, we only adde... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | 31e4db13a9e20081f2fac78f441659a6576e582bbb15e153f9c7fb6473aa29f5 |
| 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 | fb70bd3c4b2bec429781b65419e912c66e2d5581 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width