Title: Design Meeting Notes, 1/18/2023 · Issue #52296 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 1/18/2023 · Issue #52296 · microsoft/TypeScript
X Title: Design Meeting Notes, 1/18/2023 · Issue #52296 · microsoft/TypeScript
Description: newLine and forceConsistentFileNames Defaults #51909 newLine to lf? Didn't get to discuss it thoroughly. Change default of forceConsistentFileNames to true? Catch issues between Windows/Mac/Linux ahead of pushing out to CI. We think it's...
Open Graph Description: newLine and forceConsistentFileNames Defaults #51909 newLine to lf? Didn't get to discuss it thoroughly. Change default of forceConsistentFileNames to true? Catch issues between Windows/Mac/Linux a...
X Description: newLine and forceConsistentFileNames Defaults #51909 newLine to lf? Didn't get to discuss it thoroughly. Change default of forceConsistentFileNames to true? Catch issues between Windows/Mac/Lin...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/52296
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 1/18/2023","articleBody":"# `newLine` and `forceConsistentFileNames` Defaults\r\n\r\n#51909\r\n\r\n* `newLine` to `lf`?\r\n * Didn't get to discuss it thoroughly.\r\n* Change default of `forceConsistentFileNames` to `true`?\r\n * Catch issues between Windows/Mac/Linux ahead of pushing out to CI.\r\n * We think it's good to turn on.\r\n* We all feel okay about the fact that it doesn't \"do what people think\", right?\r\n * \"What?\"\r\n * It doesn't check whether the paths match what's on disk, it just checks whether the paths are consistent across the project.\r\n* Deprecate it?\r\n * Prefer not to.\r\n* Conclusion\r\n * `--newLine lf` by default.\r\n * `--forceConsistentFileNames true` by default.\r\n\r\n# `catch` Clause Variables\r\n\r\n#52240\r\n\r\n```ts\r\n// @useUnknownInCatchVariables: false\r\n\r\ntry {} catch ({ e }) {}\r\n// ^?\r\n\r\ntry {} catch ({ e }: any) {}\r\n// ^?\r\n\r\ntry {} catch ({ e }: unknown) {}\r\n// ^?\r\n\r\n\r\ntry {} catch ({ x: { e } }) {}\r\n// ^?\r\n\r\ntry {} catch ({ x: { e } }: any) {}\r\n// ^?\r\n\r\ntry {} catch ({ x: { e } }: unknown) {}\r\n// ^?\r\n```\r\n\r\n* Toggle `useUnknownInCatchVariables` between `true` and `false`.\r\n* When `true`, the annotations are ignored, and destructured declarations are permitted and `unknown`.\r\n* #52240 fix this.\r\n* Breaking change, but only found buggy code under `useUnknownInCatchVariables`.\r\n * We think this is good for 5.0.\r\n* Also: #52280 allows arbitrary type annotations on catch variables - addresses #20024.\r\n * But we're not doing that, right?\r\n * No, blatantly unsafe.\r\n * Well then we should tell people that we're not doing it?\r\n * Context matters - we think pattern matching progressing in TC39 is going to enable a safe version of this pattern.\r\n * We want to defer to that.\r\n* Conclusion\r\n * We're not doing #52280.\r\n * We're doing #52240.\r\n\r\n# Comparison Operators\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/52036\r\nhttps://github.com/microsoft/TypeScript/pull/52048\r\n\r\n* Some obvious but questionable things that popped up.\r\n * `Number \u003c number` now disallowed\r\n * `string | number \u003c number` now disallowed\r\n * `unknown \u003c number` now disallowed\r\n* Some stuff that fails due to control flow limitations across functions.\r\n* What about objects that coerce to `number` (e.g. `Date`)?\r\n * Why don't we look at `valueOf`?\r\n * Or `[Symbol.toPrimitive]`?\r\n * Here we go...\r\n* Conclusion: Feels like this PR is a good start. Want to bring this in for 5.0.\r\n * Watch for 5.0 Beta feedback.\r\n\r\n# `JSON.stringify`\r\n\r\n#51897\r\n#52250\r\n\r\n* This thing broke some code.\r\n* Technically `stringify` can return `undefined`.\r\n * But technically also wrong because a `Function` can have a `toJSON` method.\r\n* There's a world where we could possibly keep this as-is if we reordered the signatures so that `never` works.\r\n * Overload resolution goes through a subtype pass.\r\n* But why are we adding this overload? Who ends up in a situation like this?\r\n * Doesn't even catch mistakes like `(() =\u003e string) | string` today.\r\n * Only contrived cases are caught.\r\n* The idea that everyone has to suffer for `stringify` because of these contrived-but-uncommon cases feels unreasonable.\r\n* Could ship an open-ended union?\r\n* Could also just tell people to interface-merge.\r\n* Conclusion:\r\n * Revert this, tell people to interface-merge on `JSON` with something that returns `undefined`.\r\n\r\n# Picking Between Types from Type Predicates and Original Types\r\n\r\n#50916\r\n\r\n* Made a change a while back to pick the types from type predicates/type assertions.\r\n* Similar behavior with `instanceof` too.\r\n* Means that the original type does not survive at joining points of CFA.\r\n* Idea\r\n * In the true branch, we will still prefer the type predicate type.\r\n * In the false branch, we will now *preserve* the original type so that they join back at a CFA merge node.\r\n* So what do we now do about mutual subtypes?\r\n * For example, `unknown` and `any` are mutual subtypes.\r\n * Today we choose the type with the lowest ID.\r\n * Pretty unfortunate - these have measurable effects.\r\n * So we are making `any` a *strict supertype* of `unknown`.\r\n * Behavior directly in unions is the same.\r\n * Where else does this appear?\r\n * When the type IDs are not compared directly.\r\n * So for e.g. `Array\u003cany\u003e` vs. `Array\u003cunknown\u003e` - but `Array` is not special.\r\n\r\n ```ts\r\n type Box\u003cT\u003e = { readonly value: T };\r\n\r\n declare let anyBox: Box\u003cany\u003e;\r\n declare let unknownBox: Box\u003cunknown\u003e;\r\n\r\n let boxes1 = [anyBox, unknownBox];\r\n // ^?\r\n let boxes2 = [unknownBox, anyBox];\r\n // ^?\r\n ```\r\n * Now you always end up with `Box\u003cany\u003e[]`.\r\n * Similar constraints with `{}` and any non-empty object type.\r\n* What other effects does this have?\r\n * The type of an assignment expression is always the right side:\r\n\r\n ```ts\r\n function f(obj: { a?: string }) {\r\n (obj = {}).a; // allowed?\r\n }\r\n ```\r\n\r\n * Hmm...\r\n\r\n ```ts\r\n function f(a: { x?: number }, b: { x?: string}) {\r\n a = b = {}; // allowed?\r\n // Equivalent to `a = (b = {})` which naively looks like `b = {}; a = {}` from a type perspective.\r\n\r\n a.x = 42;\r\n\r\n b.x?.toUpperCase();\r\n }\r\n ```\r\n * Fresh `{}` object type has \"inverted\" subtype behavior.\r\n * It is, but on the assignment we widen.\r\n * Do we have to widen? Could choose not to.\r\n * Feels like for the `b = {}`, we have to propagate out some information, or further narrow based on the left side(?)\r\n * `(...args: any[]) =\u003e any` should be a super-type of all functions?\r\n * But what about `(...args: never[]) =\u003e unknown`?\r\n * Not specially understood today by TS internals.\r\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2023-01-18T23:19:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/52296/TypeScript/issues/52296"}
| 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:0b1e4d00-8939-ead0-dfb4-26ade013ddf0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD74:1723F3:615774:83D564:6A627C3E |
| html-safe-nonce | 8bc08b525f361f4679ba302a852461d721d07c175d7e4c6754fce11a8a842866 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDc0OjE3MjNGMzo2MTU3NzQ6ODNENTY0OjZBNjI3QzNFIiwidmlzaXRvcl9pZCI6IjE4NzY3MjY2MTc5MzI0NjMxNjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bc494fa73230872a3aa994b75d13a10b91fc7c980b4093794b9677ae5a6a0513 |
| hovercard-subject-tag | issue:1548267332 |
| 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/52296/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf272ba446507e8b07ff7ae99be1701286b86abb1dc8ae9928f3e5e5dc91a1c3/microsoft/TypeScript/issues/52296 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf272ba446507e8b07ff7ae99be1701286b86abb1dc8ae9928f3e5e5dc91a1c3/microsoft/TypeScript/issues/52296 |
| og:image:alt | newLine and forceConsistentFileNames Defaults #51909 newLine to lf? Didn't get to discuss it thoroughly. Change default of forceConsistentFileNames to true? Catch issues between Windows/Mac/Linux a... |
| 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 | 838e87bd0e4f5415707a930bc14e89e382dc2ea046e50ff575252eb2f2cb06a2 |
| 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 | f0081192f88523d2bf4cfdf22bb3e138affc4cd1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width