Title: Design Meeting Notes, 3/9/2018 · Issue #22445 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 3/9/2018 · Issue #22445 · microsoft/TypeScript
X Title: Design Meeting Notes, 3/9/2018 · Issue #22445 · microsoft/TypeScript
Description: Narrowing & Combining Higher Order Types #20673 #21369 #15100 #22096 #21182 #15643 #19469 #14967 #15376 #18902 We've been somewhat inconsistent about narrowing. "Well, we're consistent, but we don't narrow constraints." But sometimes we ...
Open Graph Description: Narrowing & Combining Higher Order Types #20673 #21369 #15100 #22096 #21182 #15643 #19469 #14967 #15376 #18902 We've been somewhat inconsistent about narrowing. "Well, we're consistent, but we don'...
X Description: Narrowing & Combining Higher Order Types #20673 #21369 #15100 #22096 #21182 #15643 #19469 #14967 #15376 #18902 We've been somewhat inconsistent about narrowing. "Well, we're consis...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/22445
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 3/9/2018","articleBody":"# Narrowing & Combining Higher Order Types\r\n\r\n#20673\r\n#21369\r\n#15100\r\n\r\n#22096\r\n\r\n#21182\r\n#15643\r\n#19469\r\n#14967\r\n#15376\r\n#18902\r\n\r\n* We've been somewhat inconsistent about narrowing.\r\n * \"Well, we're consistent, but we don't narrow constraints.\"\r\n * But sometimes we do intersections, sometimes we narrow unions, etc.\r\n\r\nToday:\r\n\r\n```ts\r\nfunction f\u003cT>(x: T) {\r\n if (typeof x === \"string\") {\r\n // 1: 'x' has type 'T & string' here.\r\n }\r\n\r\n if (x != null) {\r\n // 2: nothing happens here\r\n }\r\n}\r\n```\r\n\r\n* At `1`, treating this as an intersection here is likely correct.\r\n * But the problem is that we're not sure that, when performing instantiation, you really want to absorb more general types to their more derived types (e.g. `number & 100` becomes `100`) because this can affect contextual types, etc.\r\n * It seems like it's ostensibly okay for intersections; not necessarily for unions.\r\n * You are strictly losing types from unions.\r\n* At `2`, you want to find a way to remove `null` and `undefined`.\r\n * Can use the `NonNullable` type helper within the compiler.\r\n * In fact, can use a lot of more general machinery\r\n * #22348\r\n * Definitely worth experimenting with.\r\n* Conclusion: not a 2.8-bound change, but let's experiment with using the user-land type operators.\r\n\r\n# Should we allow indexed access types on nullable\r\n\r\n#14366\r\n\r\n* Current PR allows you to access *any* branch in a union.\r\n* Currently, you'll get different behavior if you index into a generic type parameter vs. its instantiation.\r\n * Well, yeah.\r\n* Maybe we should just give people a `!` type operator since that's what people originally asked for.\r\n* Conclusion?\r\n * We have a solution now anyway; less change in the type system itself is more desirable.\r\n * Hold off.\r\n\r\n# Type imports at arbitrary locations\r\n\r\n#14844\r\n\r\n```ts\r\n// import * as _foo from \"./foo\";\r\n// let x: typeof _foo;\r\nlet x: import(\"./foo\");\r\n\r\n// import { Foo } from \"./foo\";\r\n// let y: Foo;\r\nlet y: import(\"./foo\").Foo;\r\n```\r\n\r\n* What about confusion with the `import` operator that returns a `Promise`?\r\n * Probably not that confusing.\r\n* What about `esModuleInterop`.\r\n * Sounds like you're doomed to the same problems.\r\n * `import(\"foo\").default` for `export = `.\r\n\r\n# JSDoc type imports\r\n\r\n#22160\r\n\r\n* Just have people use `typedef`s with the new syntax.\r\n\r\n```ts\r\n/**\r\n * @typedef {import(\"foo\").default}\r\n */\r\n```\r\n\r\n* Hold off on any new syntax.\r\n\r\n# Generics in JSX\r\n\r\n#22415\r\n\r\n* Parsing is fine.\r\n* Let's do this.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2018-03-09T20:04:24Z","url":"https://github.com/microsoft/TypeScript/issues/22445"}
| 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:77ed31b1-c10f-6f74-22ea-057f86e1d6be |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA12:2E5652:AC33E6:DC3D06:6B00F670 |
| html-safe-nonce | 64e4ca3787fb77088016828402390526d87ec76a9593c14460feeb8cd68d1630 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTEyOjJFNTY1MjpBQzMzRTY6REMzRDA2OjZCMDBGNjcwIiwidmlzaXRvcl9pZCI6IjUxOTQ1MTc1MTQ2OTYwNjI1NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dd332f951cd9fcbe053590bdc22e60e9b6fb021b7bb25efe240efd90f850f664 |
| hovercard-subject-tag | issue:303963851 |
| 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/22445/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c2bd991937fe104f145ce1d6b783f7b8c4cda51e1275ba066a1114e7d704d02/microsoft/TypeScript/issues/22445 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c2bd991937fe104f145ce1d6b783f7b8c4cda51e1275ba066a1114e7d704d02/microsoft/TypeScript/issues/22445 |
| og:image:alt | Narrowing & Combining Higher Order Types #20673 #21369 #15100 #22096 #21182 #15643 #19469 #14967 #15376 #18902 We've been somewhat inconsistent about narrowing. "Well, we're consistent, but we don'... |
| 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 | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width