Title: Design Meeting Notes, 11/30/2022 · Issue #51811 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 11/30/2022 · Issue #51811 · microsoft/TypeScript
X Title: Design Meeting Notes, 11/30/2022 · Issue #51811 · microsoft/TypeScript
Description: --moduleResolution hybrid Very Node-like resolution mode that is mostly targeted at bundlers and special resolvers. What's it have that's special (beyond the weird classic mode)? node_modules package lookup Extensionless Not in --moduleR...
Open Graph Description: --moduleResolution hybrid Very Node-like resolution mode that is mostly targeted at bundlers and special resolvers. What's it have that's special (beyond the weird classic mode)? node_modules packa...
X Description: --moduleResolution hybrid Very Node-like resolution mode that is mostly targeted at bundlers and special resolvers. What's it have that's special (beyond the weird classic mode)? node_modul...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/51811
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 11/30/2022","articleBody":"# `--moduleResolution hybrid`\r\n\r\n* Very Node-like resolution mode that is mostly targeted at bundlers and special resolvers.\r\n* What's it have that's special (beyond the weird `classic` mode)?\r\n * `node_modules` package lookup\r\n * Extensionless\r\n * Not in `--moduleResolution node16`/`nodenext`\r\n * Directory index lookup (i.e. look up an `index.*` file)\r\n * Not in `--moduleResolution node16`/`nodenext`\r\n * `exports` look-up from `package.json`\r\n * Not in `--moduleResolution node`\r\n * `*.ts` imports\r\n * Nothing has this today!\r\n * Only when using `--allowImportingTsExtensions`\r\n* `--allowImportingTsExtensions`\r\n * Could potentially be ported to work on other resolution\r\n * Requires `--noEmit`\r\n * Why?\r\n * When we emit, we will ***not*** rewrite the import paths. So\r\n \r\n ```ts\r\n import * as foo from \"./foo.ts\"`\r\n ```\r\n\r\n will remain the same in the output `.js` file:\r\n\r\n ```js\r\n import * as foo from \"./foo.ts\"`\r\n ```\r\n\r\n and this will fail in most tools if `foo` was also rewritten to a JavaScript file named `foo.js`!\r\n * Basically *some other tool* is going to either handle compilation of the files, or resolution of the files directly - so \r\n* We keep talking about what a bundler does (in the meeting) - why isn't this just called `--moduleResolution bundler`?\r\n * Other loaders/runtimes like ts-node, bun, etc.\r\n * Even if it's not perfect, `bundler` communicates more than `bundler`\r\n* What else is controversial other than the name?\r\n* More options than just `allowImportingTsExtensions`\r\n * `allowImportingTsExtensions` (already mentioned)\r\n * `resolvePackageJsonExports` - resolve from the `exports` field the way Node.js 12+ does today (which we do under the `node12`/`nodenext` flag)\r\n * `resolvePackageJsonImports` - resolve from the `imports` field the way Node.js 16+ does today (which we do under the `node12`/`nodenext` flag)\r\n * `customConditions` \r\n* Does `customConditions` need \r\n* We would prefer there were some sort of hierarchy to the flags, but not sure.\r\n* Do we need to ship all the flags?\r\n * Browserify and Rollup don't do certain things by default.\r\n * Rollup might be okay b\r\n* Prefer to ship as is, evaluate over the rest of the release cycle.\r\n\r\n\r\n# Deprecation Plan\r\n\r\n* `--ignoreDeprecations`\r\n * Specify `\"5.0\"` to suppress all the errors that 5.x has deprecated.\r\n * When 6.0 hits, using `\"ignoreDeprecations\": \"5.0\"` becomes an error.\r\n* `--noSwitchCaseFallthrough`\r\n * We want to get out of the syntax linting business, but people likely use it.\r\n * Not a huge cost anyway.\r\n * Feels like we're keeping this.\r\n* `--out`?\r\n * Totally broken?\r\n * No it's not, only broken for `module`\r\n * Only if we give a good error message.\r\n * Deprecate.\r\n* `--charset`?\r\n * Doesn't get respected anyway.\r\n * Remove.\r\n* `--target es3`\r\n * Deprecate.\r\n * Complicates our testing infra now.\r\n* `\"prepend\": true` in project references?\r\n * We did this for ourselves - but is this widely in use?\r\n * We see one or two legit repos using it via GitHub's code search - the rest of the results seem to be duplicates of our repo.\r\n * This complicates our emit quite a bit.\r\n * okay.\r\n* Meta: we have *two-and-a-half years* to change our minds on this\r\n\r\n# Using our internal missing type\r\n\r\n#51653\r\n\r\n* Unfortunate that we have so many internal types and different flags!\r\n\r\n# `in` Operator Narrowing from Negative Checks\r\n\r\n#51339\r\n\r\n* If you have `obj: object` and write code like\r\n\r\n ```ts\r\n if (\"foo\" in obj && typeof obj.foo === \"string\") {\r\n obj.foo;\r\n }\r\n ```\r\n\r\n you would expect `obj.foo` to be valid and have the type `string`.\r\n* If you write the negative case and bail our early, you'd expect the same\r\n\r\n ```ts\r\n if (!(\"foo\" in obj) || typeof obj.foo !== \"string\") {\r\n return;\r\n }\r\n\r\n obj.foo;\r\n ```\r\n* This is the same problem as the fact that `obj` itself is narrowed in a distinct manner from `obj.foo`.\r\n * `obj` is only narrowed to have type `{ \"foo\": unknown } & object` - not compatible with anything that requires `{ foo: string }`.\r\n * However, `obj.foo` *is* narrowed to have the type `string`.\r\n * Related issues are #18758, #32399.\r\n* It would really be ideal if `obj` was narrowed to `{ foo: string } & object`, and narrowing `obj.foo` would just \"fall out\" from narrowing `obj` itself.\r\n* Can imagine that we just stack intersections as we learn more\r\n * e.g. `object & { foo: unknown } & { foo: string }` which simplifies to `object & { foo: string }`\r\n* The problem with doing that is you would end up with huge types in some cases - which adds visual noise and impacts performance.\r\n* Additionally, you can \"learn\" information by introducing intersections when narrowing types - but when you join from two branches, how do you know which intersections were \"learned\" from type guards vs. which intersections were already there.\r\n * Feels doable, making this efficient also makes this harder.\r\n * We eagerly normalize intersections which is part of what makes this challenging.\r\n* There's a silver lining - simplifying narrowing to just narrow the roots of references would make us more efficient in other ways.\r\n * Also, deferring intersections could be faster.\r\n* Is this compelling?\r\n * Lots of feedback on this issue.\r\n * Spent a lot of time on this (e.g. #38839)\r\n * There's also lots of UX weirdness in the language service as well (#51526)\r\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2022-12-08T01:57:51Z","url":"https://github.com/microsoft/TypeScript/issues/51811"}
| 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:323a13ce-8b6a-e29f-6da4-4bb010325227 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88AE:15CF5E:D2364E:11F9F0E:6B05BEFD |
| html-safe-nonce | 762be3e4f3de6f3fca019fb4248c50d7d86d636e5c71aa7c43815f6759a913e9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEFFOjE1Q0Y1RTpEMjM2NEU6MTFGOUYwRTo2QjA1QkVGRCIsInZpc2l0b3JfaWQiOiI1NDE1MzQyNDg1MTI2MTAyNzgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f7edd4d64ae7b552f2b7cc0e6c9f5f124f2dce25d91881678191f1bc8f5b3683 |
| hovercard-subject-tag | issue:1483362920 |
| 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/51811/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5645831f634b91b9ee1a2dc7a3278eb37df7148986d6bd9a711e8c5e16508df2/microsoft/TypeScript/issues/51811 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5645831f634b91b9ee1a2dc7a3278eb37df7148986d6bd9a711e8c5e16508df2/microsoft/TypeScript/issues/51811 |
| og:image:alt | --moduleResolution hybrid Very Node-like resolution mode that is mostly targeted at bundlers and special resolvers. What's it have that's special (beyond the weird classic mode)? node_modules packa... |
| 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 | 708c2f10d746dbcf1dd80dc8309daa7d595df3fce8066244380fc3238618f09c |
| 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 | 2a29e3cf4fb57e81fd311774f91f345cc4436f40 |
| 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