Title: Design Meeting Notes, 9/8/2017 · Issue #18339 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 9/8/2017 · Issue #18339 · microsoft/TypeScript
X Title: Design Meeting Notes, 9/8/2017 · Issue #18339 · microsoft/TypeScript
Description: Reduce vacuous intersections When we talk about unions and intersections we are talking about domains - sets which contain a number of values. Specifically, when you have an intersection, you have a type that describes values that occupy...
Open Graph Description: Reduce vacuous intersections When we talk about unions and intersections we are talking about domains - sets which contain a number of values. Specifically, when you have an intersection, you have ...
X Description: Reduce vacuous intersections When we talk about unions and intersections we are talking about domains - sets which contain a number of values. Specifically, when you have an intersection, you have ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18339
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 9/8/2017","articleBody":"# Reduce vacuous intersections\r\n\r\n* When we talk about unions and intersections we are talking about domains - sets which contain a number of values.\r\n* Specifically, when you have an intersection, you have a type that describes values that occupy each constituent of the intersection.\r\n* However, for certain sets of types that are completely disjoint, you have a completely empty domain of values.\r\n* And the type that describes the set of no values is simply `never`.\r\n* So for certain types (e.g. `number & string` or `\"foo\" & \"bar\"`), it makes sense to collapse them down to `never`.\r\n* There's some strange behavior that might come about from this:\r\n ```ts\r\n var s: string;\r\n var x: string & number; // does the quick info here become 'never'? The user didn't write that.\r\n var b: boolean = x; // you can also assign to anything all of a sudden\r\n // even though 'string & number' doesn't contain 'boolean'\r\n ```\r\n* We also get quite large slowdowns - @weswigham's experimental branch of discriminated union nodes takes *minutes* to compile.\r\n* So maybe we don't want to go all the way there. But for unit types, we certainly care.\r\n* Current behavior in the compiler:\r\n\r\n ```ts\r\n type ABC = \"A\" | \"B\" | \"C\";\r\n type BCD = \"B\" | \"C\" | \"D\";\r\n type X = ABC & BCD;\r\n // Becomes...\r\n // | \"B\" | \"C\" | (\"A\" & \"D\") | (\"A\" & \"B\") |\r\n // | (\"A\" & \"C\") | (\"B\" & \"D\") | (\"B\" & \"C\")\r\n // | (\"C\" & \"D\") | (\"C\" & \"B\")\r\n ```\r\n* What about objects with properties that collapse to `never`?\r\n * Technically, `Circle & Square` (where each has a discriminated unit-typed property) should become `never` since the `kind` or `type` or whatever discriminating field will become `never` as well.\r\n * Problem is that turning this into `never` becomes sort of opaque - no clue to the user how they got there.\r\n * Also can't diagnose the properties, though arguably you should be able to get properties off of a value of type `never`.\r\n* Idea: current implementation just removes these vacuous unit intersection types when constructing unions.\r\n * Means they'll get removed from explicit unions, but you can have a single intersection (outside of a union) that is a vacuous intersection of ujnit types.\r\n\r\n* Related issue: https://github.com/Microsoft/TypeScript/issues/18210\r\n * Maybe revisit next week.\r\n * Current idea is stitching nullability back on after the fact.\r\n\r\n# Export assignment\r\n\r\nhttps://github.com/Microsoft/TypeScript/issues/17991\r\nhttps://github.com/Microsoft/TypeScript/issues/16769\r\n\r\n* What do you think this code does?\r\n\r\n ```ts\r\n declare module \"*.vue\" {\r\n import Vue from 'vue'\r\n export default typeof Vue\r\n }\r\n ```\r\n\r\n* You're probably wrong.\r\n* A: ˙ǝdʎʇ ,ƃuᴉɹʇs, ǝɥʇ s,ʇI\r\n\r\n* Ideas\r\n * We should disallow expressions in ambient contexts.\r\n * Or ensure these ambiguous entities are parsed appropriately.\r\n* What about `export default class`?\r\n * Will be different, `default` is treated as a modifier here?\r\n\r\n## Revision to tagged template string emit\r\n\r\nhttps://github.com/Microsoft/TypeScript/pull/18300\r\n\r\n- We originally opted into a simple implementation\r\n - the simplest solution was to recreate the array\r\n - leaves the code clean\r\n- frameworks like lit-html take a dependency on the identity of the template, obviously our current behavior beaks them\r\n\r\nemit options:\r\n- cache globally to match the current spec\r\n - the spec is actually going to change, there is an issue on TC39 to only make that unique per template\r\n- defer the use until \r\n\r\n- what about variable names, could collide in cases of global scripts\r\n - in global scripts, revert back to old behavior\r\n - this would be confusing to users to have different semantics based on the context\r\n - is not that the same as destructuring?\r\n - destructuring only uses the variable for a short while during initialization, but templates has higher chance of conflicts\r\n - make names unique, either use some hash of the contents, or the template location\r\n - @danielRosenwasser to figure this one out.\r\n\r\n# Merge contextual types from overloads\r\n\r\nhttps://github.com/Microsoft/TypeScript/pull/17819\r\n\r\n* Currently if a function is contextually typed by a type with multiple signatures (e.g. overloads), we \"give up\" and go to 'any'.\r\n * Comes up in JSX where `props` has a specific `refs` type or when another type extends another component.\r\n\r\nOut of time","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2017-09-08T19:59:59Z","url":"https://github.com/microsoft/TypeScript/issues/18339"}
| 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:dcdc1555-ff10-2d79-031e-be4fa5063c60 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 91A2:31D532:3A7788:4D2E9F:6B019411 |
| html-safe-nonce | abb5a5fafca3aa36f61ea9308efd5c64282c2aaf0075d815b89f263cdc6637f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUEyOjMxRDUzMjozQTc3ODg6NEQyRTlGOjZCMDE5NDExIiwidmlzaXRvcl9pZCI6IjYzNTg2NjM4OTkxNTExNzY3MjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 436f393c575521c8518d4038ff7e64b12e6fda357051ce5e77f7f6c3ec8c36d0 |
| hovercard-subject-tag | issue:256356481 |
| 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/18339/issue_layout |
| twitter:image | https://opengraph.githubassets.com/81751013128fb9e80853557fa3bd9cc890a8e66a25af0f3050084885fd80facd/microsoft/TypeScript/issues/18339 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/81751013128fb9e80853557fa3bd9cc890a8e66a25af0f3050084885fd80facd/microsoft/TypeScript/issues/18339 |
| og:image:alt | Reduce vacuous intersections When we talk about unions and intersections we are talking about domains - sets which contain a number of values. Specifically, when you have an intersection, you have ... |
| 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 | 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width