Title: Design Meeting Notes, 9/8/2023 · Issue #55689 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 9/8/2023 · Issue #55689 · microsoft/TypeScript
X Title: Design Meeting Notes, 9/8/2023 · Issue #55689 · microsoft/TypeScript
Description: Recognizing Symbol.hasInstance in instanceof Narrowing #55052 Previous discussion at #55325 TypeScript currently doesn't recognize anything about Symbol.hasInstance when performing an instanceof. PR considers [Symbol.hasInstance]-declare...
Open Graph Description: Recognizing Symbol.hasInstance in instanceof Narrowing #55052 Previous discussion at #55325 TypeScript currently doesn't recognize anything about Symbol.hasInstance when performing an instanceof. P...
X Description: Recognizing Symbol.hasInstance in instanceof Narrowing #55052 Previous discussion at #55325 TypeScript currently doesn't recognize anything about Symbol.hasInstance when performing an instanceo...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/55689
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 9/8/2023","articleBody":"# Recognizing `Symbol.hasInstance` in `instanceof` Narrowing\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/55052\r\n\r\n* Previous discussion at https://github.com/microsoft/TypeScript/issues/55325\r\n* TypeScript currently doesn't recognize anything about `Symbol.hasInstance` when performing an `instanceof`.\r\n* PR considers `[Symbol.hasInstance]`-declared methods that are declared as type guards.\r\n* When you do this, it changes narrowing very slightly.\r\n * Kind of merges the behavior of type predicates narrowing and narrowing via derivedness checks.\r\n * Specific exceptions regarding `any`.\r\n* Seems okay, just needs review.\r\n\r\n# Improve portability of resolution-mode assertions automatically emitted in `nodenext`\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/55579\r\n\r\n* Now seeing `/// \u003creference types=\"...\" />` directives getting generated with `resolution-mode=\"require\"` in declaration emit.\r\n* Not everyone is using the same TS version, resolution options.\r\n* Need to either make TS more lenient or generate these resolution-mode attributes appear less-often.\r\n* TypeScript will generate these `/// \u003creference types />` directives to ensure broader compatibility for consumers.\r\n* When TypeScript encounters `/// \u003creference types=\"chai\" />` from an ES module, we try to do an import to `chai`, not find a `.` export in `chai`'s `package.json`, and fall back to the CommonJS types anyway.\r\n* Could we just support `resolution-mode` regardless of any settings?\r\n * Probably, and could even for `import type`.\r\n* Very weird that the `types` compiler option doesn't support this.\r\n\r\n# Tracking Recursion Identity of Homomorphic Mapped Types Based On Their Target Symbol\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/55638\r\n\r\n```ts\r\ntype Id\u003cT> = { [K in keyof T]: Id\u003cT[K]> };\r\n\r\ntype Foo1 = Id\u003c{ x: { y: { z: { a: { b: { c: number } } } } } }>;\r\ntype Foo2 = Id\u003c{ x: { y: { z: { a: { b: { c: string } } } } } }>;\r\n\r\ndeclare const foo1: Foo1;\r\nconst foo2: Foo2 = foo1; // Errors with PR, previously didn't.\r\n```\r\n\r\n* When tracking if `Foo2` is compatible with `Foo1`, we would say \"We saw `Id\u003c*Something*>` too many times\".\r\n * This was based on using the identity of `Id` itself when tracking recursive instantiation.\r\n* Now, if `*Something*` is a type with a symbol, we use that as the identity.\r\n* Breaks the raphael package on DefinitelyTyped. Can be fixed with `in out`.\r\n * Alternative fix is for these mapped types to be broken up into named types.\r\n* How does this work for nested mapped types?\r\n\r\n ```ts\r\n type Expand\u003cT> = {\r\n [K in keyof T]: Expand\u003cExpand\u003cT[K]>>\r\n };\r\n ```\r\n * We drill through to find the identity.\r\n * Need a test case.\r\n* Technically you can still hit issues between non-identical mapped types.\r\n\r\n# Enabling `fetch` in Node.js\r\n\r\nhttps://github.com/DefinitelyTyped/DefinitelyTyped/issues/60924\r\n\r\n* The DOM has a global `fetch` function and a few related global classes.\r\n* As of Node 20, Node.js has a compatible global `fetch`.\r\n* They're compatible, but not *identical*.\r\n* This is a problem because a lot of users with front-end projects accidentically end up including Node's types - either via misconfiguration or a \"rogue\" package in `node_modules`.\r\n* Two solutions.\r\n * One is through a level of indirection where the global types extend aliases from Unici. They are conditionally extended from Undici based on whether the global scope includes some amount of information from the DOM.\r\n * Downside: hard dependency on Undici, which is fairly large as a package. 1MB because it doesn't just include types. Have to worry about versioning.\r\n * Technically, Undici is shipped within Node.js, but only kinda exposed. Similarly, `fs.rm` is actually rimraf under the hood. (!)\r\n * Alternatively, duplicate all the contents of `fetch`. About 600 lines, so not small.\r\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2023-09-08T19:15:38Z","url":"https://github.com/microsoft/TypeScript/issues/55689"}
| 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:8cd794d1-f85d-19cb-76f0-9d06f15dd577 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A132:E9D16:1F42972:279FA14:6B01A219 |
| html-safe-nonce | b8e20de42864d2ac40ad64c6c42c43ff29cf81a7a7c8d20f74f051920f6ec656 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTMyOkU5RDE2OjFGNDI5NzI6Mjc5RkExNDo2QjAxQTIxOSIsInZpc2l0b3JfaWQiOiIyMzEyODkzMTIxNDkzNDg4ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9732366bb29f75fe3e51b1929267721c685765164621f1f7e36b0a5db1708ce2 |
| hovercard-subject-tag | issue:1888194766 |
| 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/55689/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dd184ebf2cd6d5bf3da7d2689b61118dbe8e102e84bbf19e52842f55f64b4c23/microsoft/TypeScript/issues/55689 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd184ebf2cd6d5bf3da7d2689b61118dbe8e102e84bbf19e52842f55f64b4c23/microsoft/TypeScript/issues/55689 |
| og:image:alt | Recognizing Symbol.hasInstance in instanceof Narrowing #55052 Previous discussion at #55325 TypeScript currently doesn't recognize anything about Symbol.hasInstance when performing an instanceof. P... |
| 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