Title: Design Meeting Notes, 6/18/2020 · Issue #39154 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 6/18/2020 · Issue #39154 · microsoft/TypeScript
X Title: Design Meeting Notes, 6/18/2020 · Issue #39154 · microsoft/TypeScript
Description: Variadic Tuples #39094 Added the ability to add a "cut point" to inference to accurately describe curry. function curry
Open Graph Description: Variadic Tuples #39094 Added the ability to add a "cut point" to inference to accurately describe curry. function curry
X Description: Variadic Tuples #39094 Added the ability to add a "cut point" to inference to accurately describe curry. function curry<T extends unknown[], U extends unknown[], R>( f: (...args: [....
Opengraph URL: https://github.com/microsoft/TypeScript/issues/39154
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 6/18/2020","articleBody":"# Variadic Tuples\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/39094\r\n\r\nAdded the ability to add a \"cut point\" to inference to accurately describe `curry`.\r\n\r\n```ts\r\nfunction curry\u003cT extends unknown[], U extends unknown[], R>(\r\n f: (...args: [...T, ...U]) => R,\r\n ...a: T\r\n)\r\n```\r\n\r\nThis is complicated! Why?\r\n\r\n* You want to get the count from `...a` to know how much to cut off from [...T, ...U]`\r\n* You want `...a` to be contextually typed by whatever it could be inferred from `...args`\r\n* So we now try to build up a concept of \"implied arity\" from these positions during the inference process.\r\n\r\nThere are some limitations around inference in certain more complex cases.\r\n\r\n```ts\r\nfunction independent\u003cT extends unknown[], R>(\r\n ...args: [...T, (...a: T) => R]\r\n): [T, R];\r\n```\r\n\r\nWorks well for\r\n\r\n```ts\r\n[fixed-part, ...rest-part]\r\n```\r\n\r\nbut not\r\n\r\n```ts\r\n[starting-fixed-part, ...rest-part, ending-fixed-part]\r\n[...rest-part, fixed-part]\r\n```\r\n\r\nbut...we think we could! Then we could model\r\n\r\n```ts\r\ndeclare const foo: string[];\r\n\r\nindependent(...foo, (...args) => hello)\r\n```\r\n\r\n* What about `pipe`?\r\n * Common, but is very complicated to type without pyramids of overloads.\r\n * There's also compose which is more right to left, which we couldn't do.\r\n * Wasn't within scope for this PR.\r\n * Maybe potential in the future, but also, maybe `|>` is the better solution.\r\n* We had some questions about applying mapped type transformations across different places.\r\n * Turns out that we don't encode the right information to say that when constrained to a union of array/tuple types, a homomorphic mapped type will also be array/tuple-like.\r\n * Instead, we just assume that the thing is more plain object-like than array-like.\r\n * Basically the same as behavior of mapped types on arrays before they were special-cased in around TS2.9ish.\r\n\r\n# Spreading `anyTypeExpr && otherExpr` into Objects\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/39113\r\n\r\n```ts\r\nfunction fn(x: unknown) {\r\n const res = {\r\n // uh oh!\r\n // 'prop' is specified more than once, so this usage will be overwritten.\r\n prop: 100,\r\n // This spread always overwrites this property.\r\n ...(x && { prop: 200 }),\r\n };\r\n}\r\n```\r\n\r\nStrange:\r\n\r\n```ts\r\nlet x: string = (false as unknown) && \"hello\"; // okay\r\nlet y: string = (0 as number) && \"hello\"; // error\r\n```\r\n\r\nConclusion: Try changing this behavior and see what breaks, but it sounds very breaky.\r\n\r\n# Switch to ES `Maps` and `Sets`\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/33771\r\n\r\n* Internally we have a `Map` type, have logic that uses the native ES `Map` type if available.\r\n* But the problem is, because our polyfill only worked on `string`s keys, our `Map` was limited like that all-around.\r\n* Will switch to having `K, V`.\r\n* `WeakMap`?\r\n * Not if we can help it, avoid using in compiler.\r\n* What about breaking change?\r\n * Very esoteric use-sites in our API.\r\n* Conclusion: Try the change in beta, work with build tool authors to see impact.\r\n\r\n______\r\n\r\nOut of time\r\n\r\n# Base tsconfigs\r\n\r\nhttps://github.com/tsconfig/bases/pull/15\r\n\r\n# Abstract Constructor Types\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/36392","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2020-06-18T21:59:01Z","url":"https://github.com/microsoft/TypeScript/issues/39154"}
| 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:60f11247-66b8-7f70-1cb2-a246f6f4868f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9F6:34DB8F:1A90401:2376EDC:6B016092 |
| html-safe-nonce | a9153545ea0f3e30f9b58d3f88e8ff2d367368f518c0cb5c3c94a52502a1ab3f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUY2OjM0REI4RjoxQTkwNDAxOjIzNzZFREM6NkIwMTYwOTIiLCJ2aXNpdG9yX2lkIjoiMTEzNDQ5MzAwODYyMDc3MzUyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c3a0c4569d4bc2f5b030dfea20482d44ae1d84b43a14624f12ed2599d8e152d7 |
| hovercard-subject-tag | issue:641573967 |
| 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/39154/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8bb24f7092f200aca75684a8829741b258ad17a8b7878e4a4c818f5af9362923/microsoft/TypeScript/issues/39154 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8bb24f7092f200aca75684a8829741b258ad17a8b7878e4a4c818f5af9362923/microsoft/TypeScript/issues/39154 |
| og:image:alt | Variadic Tuples #39094 Added the ability to add a "cut point" to inference to accurately describe curry. function curry |
| 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