Title: Design Meeting Notes, 1/11/2019 · Issue #29382 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 1/11/2019 · Issue #29382 · microsoft/TypeScript
X Title: Design Meeting Notes, 1/11/2019 · Issue #29382 · microsoft/TypeScript
Description: Readonly generalizations We've had a smattering of issues that relate to readonly. Also, we have a Readonly
Open Graph Description: Readonly generalizations We've had a smattering of issues that relate to readonly. Also, we have a Readonly
X Description: Readonly generalizations We've had a smattering of issues that relate to readonly. Also, we have a Readonly<T> today. We made changes so that homomorphic mapped types (like Partial<T&g...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29382
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 1/11/2019","articleBody":"# `Readonly` generalizations\r\n\r\n* We've had a smattering of issues that relate to `readonly`.\r\n* Also, we have a `Readonly\u003cT>` today.\r\n * We made changes so that homomorphic mapped types (like `Partial\u003cT>`) work on tuples\r\n * But there's no `readonly` modifier for tuple properties\r\n * And `Readonly` doesn't specially treat arrays.\r\n* Proposing so that\r\n * type system could make readonly slots in tuples\r\n * transforms arrays to produce `ReadonlyArray`.\r\n* Could this help make `Array.isArray` work correctly for `ReadonlyArray`s?\r\n * Maybe.\r\n* There's on little nit to it\r\n * The fact that `Array` is not assignable to `ReadonlyArray`, but a `T` is assignable to a `Readonly\u003cT>`.\r\n * This is not the \"end of the world\".\r\n* Concern: I don't like this because introducing what appears to be a minor inconsistency can have larger downstream effects.\r\n * https://github.com/Microsoft/TypeScript/issues/27375\r\n * Rationale: we already generalized `Readonly` to make things readonly-ish consistently, we should generalize this.\r\n\r\n# `readonly` expression operator\r\n\r\n* People keep running into issues where things widen because of mutability, and it bugs the hell out of them.\r\n* Ideas:\r\n * if contextually typed by something that's readonly, you should keep around readonliness\r\n * \"You mean `Readonly\u003cT>`, or just something with `readonly` properties?\"\r\n* Are we concerned with adding something to the expression space? Could we just have a `readonly` keyword that you contextual type, or using `as readonly` or `as const`?\r\n * You don't always have a good contextual space.\r\n * Definitely a concern about introducing new syntax, but trailing syntax is hard to read.\r\n * `\u003cconst>[1, 2, 3]`\r\n * Gross.\r\n * `const` might be a better keyword because `readonly` is only a \"view of the world\" guarantee; *you* can't mutate, but someone else might.\r\n\r\n# Negated types\r\n\r\n* @bterlson: I'm so excited for this\r\n* @DanielRosenwasser: I feel a bit more negative about them.\r\n\r\n* @weswigham: many of my bugs correspond to people trying to express things with strange conditional types.\r\n * What people often want is to remove things from the domain.\r\n\r\n* @rbuckton: Can I make a not-not joke?\r\n\r\n* Type relationships\r\n * `not` is related contravariantly on its contained type.\r\n * `not T` ≤ `not U` if `U` ≤ `T`\r\n * `S` ≤ `not T` if `S & T` = `never`.\r\n * Deferred (i.e. non-simplified) negated types never imply any relation with other types (i.e. `not T` ≰ `U`).\r\n* Interesting topics\r\n * Interplay with narrowing\r\n * When you narrow *out* `number` from a generic type `T`, should we intersect with `not number`? (i.e. should you get `T & not number`)?\r\n * Could we replace conditional types in #22348 with negated types? They would compose.\r\n * Sort of, except for the fake mechanism for tagging types.\r\n * We've let people abuse intersection types with vacuous domains.\r\n * Okay, imagine this\r\n * `Stringy\u003cT>` = `T & string`\r\n * `NonNullable\u003cT>` = `T & not null & not undefined`\r\n * `Truthy\u003cT>` = `T & not (0 | \"\" | false | undefined | null)`\r\n * With `let x: { a: number } | string`, narrowing with `typeof x === \"string\"` you'd end up with `string & { a: number }`.\r\n * What if you had a way to say that some of these object types *never* can overlap with another primitive.\r\n * Interplay with mapped types?\r\n\r\nOut of time","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2019-01-11T21:37:32Z","url":"https://github.com/microsoft/TypeScript/issues/29382"}
| 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:2fff07f0-b213-9839-dfc1-aaad38733ce3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D78E:28815B:DA7EAD:1245BC3:6B010267 |
| html-safe-nonce | 47b54a1e60785ae3ac44a71e78854fdfc991210cb9864b13c3876c1a492f9e50 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzhFOjI4ODE1QjpEQTdFQUQ6MTI0NUJDMzo2QjAxMDI2NyIsInZpc2l0b3JfaWQiOiI1OTY5ODcyMzY5OTExNjYxMTU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 54ad6a2ba9827483c1e82d9d4860ddb0b1ae50bd5f8cb5b0cf5be570e9b5f1ca |
| hovercard-subject-tag | issue:398460920 |
| 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/29382/issue_layout |
| twitter:image | https://opengraph.githubassets.com/464414a7023b424646d57fc82cb376d125852ee213f102577bf7c62dc39cc8f9/microsoft/TypeScript/issues/29382 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/464414a7023b424646d57fc82cb376d125852ee213f102577bf7c62dc39cc8f9/microsoft/TypeScript/issues/29382 |
| og:image:alt | Readonly generalizations We've had a smattering of issues that relate to readonly. Also, we have a Readonly |
| 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 | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width