Title: Design Meeting Notes, 1/29/2020 · Issue #42590 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 1/29/2020 · Issue #42590 · microsoft/TypeScript
X Title: Design Meeting Notes, 1/29/2020 · Issue #42590 · microsoft/TypeScript
Description: Big arrays of discriminated unions #42522 let x: Action[] = [ { type: 1, payload 42 }, { type: 2, payload 42 }, { type: 3, payload 42 }, // ... ]; Linear search on every element to see if it matches a type in Action. O(n * m), n = number...
Open Graph Description: Big arrays of discriminated unions #42522 let x: Action[] = [ { type: 1, payload 42 }, { type: 2, payload 42 }, { type: 3, payload 42 }, // ... ]; Linear search on every element to see if it matche...
X Description: Big arrays of discriminated unions #42522 let x: Action[] = [ { type: 1, payload 42 }, { type: 2, payload 42 }, { type: 3, payload 42 }, // ... ]; Linear search on every element to see if it matche...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/42590
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 1/29/2020","articleBody":"# Big arrays of discriminated unions\r\n\r\n* https://github.com/microsoft/TypeScript/pull/42522\r\n\r\n```ts\r\nlet x: Action[] = [\r\n { type: 1, payload 42 },\r\n { type: 2, payload 42 },\r\n { type: 3, payload 42 },\r\n // ...\r\n];\r\n```\r\n\r\n* Linear search on every element to see if it matches a type in `Action`.\r\n * `O(n * m)`, n = number of elements, m = number of union constituents\r\n * Also, structural comparison on each element.\r\n* A couple of places where we can optimize on these cases.\r\n* In an array literal, if we have a contextual type (and we're not in a inference-checking mode), no reason to perform subtyping.\r\n * We generally try to report element-wise on constituents of an array - but in cases where we can't, you might end up with a bigger union.\r\n* When the target side is a discriminated union, we can try to map to the right types and compare against those.\r\n * Could reuse the same logic for contextual typing by discriminated unions.\r\n\r\n# Consider Well-Known Symbols To Be `unique`\r\n\r\n* https://github.com/microsoft/TypeScript/pull/42543\r\n* https://github.com/microsoft/TypeScript/pull/24738\r\n\r\n* Came up again with https://github.com/microsoft/TypeScript/pull/24738#issuecomment-769291142\r\n* Seems to help bring us to where we'd have wanted to be if we had unique symbol 5 years ago.\r\n* Seems like we only didn't bring this in because other work came up (e.g. lib references)\r\n* `unique symbol` is no panacea, nominal results.\r\n * Seems like nominality is not a problem here.\r\n* `keyof` works now too which is neat!\r\n* `Symbol.for` is one last place where `unique symbol` still causes issues.\r\n* Conclusion: drive for 4.3.\r\n\r\n# Bitflag Enums and Non-Union Enums\r\n\r\n* https://github.com/microsoft/TypeScript/issues/42521\r\n* https://github.com/microsoft/TypeScript/pull/42533\r\n\r\n* Not opposed to adding a restriction of some sort - but opposed to adding a keyword.\r\n * `enum` is a reserved word for JS, want to make sure that we're not going in an incompatible direction.\r\n * Comment-like modifier could work.\r\n* Funny thing about the PR is that we already have union enums and \"classic\" enums.\r\n * Union enums introduce a union of different individual member types.\r\n * You get these enums when you write no initializer for you values.\r\n * We have a rule that says that `number` is not assignable to any union enum types.\r\n* Today you have to be careful because writing anything other than a literal expression throws you out of union enum land.\r\n* Returning to syntax, opportunity to find syntax after name, before brace.\r\n * Still wary of any syntax because ES could use it.\r\n* Just want a way to disable bit-flagginess/numeric behavior.\r\n* Don't necessarily want to take this PR, should consider a \"strict enum mode\".\r\n * Also, even if we wanted to take it, we couldn't/shouldn't because of the syntax concern.\r\n* More thought needed.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2021-02-01T22:51:16Z","url":"https://github.com/microsoft/TypeScript/issues/42590"}
| 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:13070829-a17f-44fc-db12-da122da46cfb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C228:BE8D0:258F46:34E5E4:6B046953 |
| html-safe-nonce | 311fc1662d6cc931a61ef006457461f6f2abaf92b311169f074af02ace0772b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjI4OkJFOEQwOjI1OEY0NjozNEU1RTQ6NkIwNDY5NTMiLCJ2aXNpdG9yX2lkIjoiMzIwNzA4MDE3OTM5NDcwMTY1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3929e18f3123222ef078e14ec6022703260a1d8073707f6a73786f5dd9eea660 |
| hovercard-subject-tag | issue:798773911 |
| 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/42590/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d83fe961c405f602a8b72a40886be55d3a02f7ef87b626fb226c7f8828f4d99/microsoft/TypeScript/issues/42590 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d83fe961c405f602a8b72a40886be55d3a02f7ef87b626fb226c7f8828f4d99/microsoft/TypeScript/issues/42590 |
| og:image:alt | Big arrays of discriminated unions #42522 let x: Action[] = [ { type: 1, payload 42 }, { type: 2, payload 42 }, { type: 3, payload 42 }, // ... ]; Linear search on every element to see if it matche... |
| 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 | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| 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 | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width