Title: Design Meeting Notes, 1/25/2019 · Issue #29588 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 1/25/2019 · Issue #29588 · microsoft/TypeScript
X Title: Design Meeting Notes, 1/25/2019 · Issue #29588 · microsoft/TypeScript
Description: Type parameters constrained to any #29571 We've had a test since forever, but TypeScript provides absolutely zero validation on usages of type parameter constrained to any. const f =
Open Graph Description: Type parameters constrained to any #29571 We've had a test since forever, but TypeScript provides absolutely zero validation on usages of type parameter constrained to any. const f = X Description: Type parameters constrained to any #29571 We've had a test since forever, but TypeScript provides absolutely zero validation on usages of type parameter constrained to any. const f = <T exte...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29588
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 1/25/2019","articleBody":"# Type parameters constrained to `any`\r\n\r\nhttps://github.com/Microsoft/TypeScript/pull/29571\r\n\r\n* We've had a test since forever, but TypeScript provides absolutely zero validation on usages of type parameter constrained to `any`.\r\n\r\n```ts\r\nconst f = \u003cT extends any\u003e(arg: T) =\u003e {\r\n arg.whut; // no error!!!!!\r\n}\r\n```\r\n\r\n* How often does this come up in practice?\r\n * When an error message says \"this isn't assignable to this constraint\", then you can imagine people just \r\n* Depends on who gets impacted.\r\n * Check [bigtestquery](https://bigtsquery.firebaseapp.com/query?selector=TypeParameter%3EAnyKeyword), other real world code.\r\n* Seems like this could break behavior in the presence of what TypeScript falls back to in failed inferences.\r\n * Nope! We see if the inferred type is assignable to the constraint, and fall back to the constraint if not. Since we infer `{}` in the presence of no inferences and that's assignable to `any`, that's okay.\r\n\r\n# Apply contextual types from inferred return types\r\n\r\nhttps://github.com/Microsoft/TypeScript/pull/29478\r\n\r\n* Seems low risk - let's see if tests come back, and if so everything can go in for 3.3.\r\n\r\n# `const` contexts\r\n\r\nhttps://github.com/Microsoft/TypeScript/pull/29510\r\n\r\nSeems like there was some confusion on naming, but looks reasonable.\r\n\r\n# Improved simplification and restrictive instantiation of conditionals\r\n\r\n#29437\r\n\r\n* Doesn't `T extend U` always being true always imply that `T` subsumes `T \u0026 U` anyway?\r\n * Mostly yes! But in the presence of circularities.\r\n* Right now this emulates what negated types *would* do.\r\n* Do we want this in 3.3?\r\n * No, not the whole thing.\r\n * The restrictive instantiation is helpful.\r\n* Rename some function as part of the PR 🤷♂️.\r\n\r\n# Unioning issues on thousands of object literals\r\n\r\nhttps://github.com/Microsoft/TypeScript/pull/28707\r\nhttps://github.com/Microsoft/TypeScript/pull/28727\r\n\r\n* Dualing PRs\r\n* Array literals with 30K distinct object literals\r\n* This isn't 3.3 bound\r\n * It's been terrible since normalization\r\n * It's been slow since union types\r\n * Probably as bad when we used to fall back to `{}`.\r\n\r\n# Negated types\r\n\r\n#29317\r\n\r\n* Want to see how it affects control flow, and first want to look into index signature unification.\r\n\r\n# Index signatures\r\n\r\n#26797\r\n\r\n* Need to unify the idea of mapped types and index signatures.\r\n* Maybe the idea here is that existing index signatures continue to work the way they do today, and any declarations of normal properties (i.e. using unions of literal types) don't have to apply.\r\n * How do you fall into this scenario?\r\n\r\n ```ts\r\n let foo: {\r\n [x: \"a\" | \"b\" | \"c\"]: boolean;\r\n [x: \"c\" | \"d\" | \"e\"]: number;\r\n };\r\n\r\n\r\n ```\r\n* Could muse about a world where every property declaration `\"foo\"` with type `T` de-sugars to `[x: \"foo\"]: T`.\r\n * With that, negated types mean you can also ensure that certain properties can be excluded from needing to satisfy index signatures.\r\n\r\n# Contextually typed parameters with binding patterns\r\n\r\n#28816\r\n\r\n* Today, when we have to determine the type of a parameter, we ask\r\n 1. Is there an annotation?\r\n 1. Is there a contextual type?\r\n 1. Is there an initializer?\r\n 1. Can we build a type *implied* by the binding pattern?\r\n* When you have a contextual type, but that contextual type is a type parameter in inference, then you run into an awkward loop.\r\n * What we arguably *should* do is say that contextual typing fixes the type parameter, and if the type parameter isn't constrained then you get inference to `{}`.\r\n * What we instead to is say there's no contextual type, try to infer from the binding pattern, and then infer to the type parameter.\r\n* Turns out this has inconsistent experiences in the IDE.\r\n* This is a breaking change under `noImplicitAny`, but we need to make a call\r\n\r\n# Different treatment of methods, functions expressions, and arrow functions\r\n\r\n#29520\r\n\r\n* In order to \"validate\" an instantiation of `T`\r\n* The subtle difference is that 0-arity arrow functions are the only ones that are not contextually sensitive.\r\n * Sure it is!\r\n * Nope! It has no `this` parameter. The others do.\r\n * So the others are contextually sensitive and deferred.\r\n* There's an expensive way to solve the problem.\r\n * We could clone the type mapper and not \"fix\" the type parameters during inference.\r\n * We can track whether the node itself contains `this`.\r\n* Could potentially see if we could make it cheaper to clone mappers.\r\n * But couldn't that fix other parameters?\r\n * \\[\\[Potentially not - @weswigham @ahejlsberg, why?]]\r\n* Possibly a design limitation, but may be interesting to tackle.\r\n* A better pattern might just be to use negated types.\r\n\r\n# Invariant predicates\r\n\r\n#26981\r\n#27686\r\n\r\n* Technically, user-defined type guards should be invariant.\r\n* Unfortunately this breaks a bunch of things that appear reasonable in real world code.\r\n* Error with `{}` to `any` because uses `isIdenticalTo`.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2019-01-25T21:26:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/29588/TypeScript/issues/29588"}
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:bd0cadc5-3219-c256-f2f9-cc9b8964e36c current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id D08C:1166E6:DDF5E0:128D84B:6A62B550 html-safe-nonce ca25f401771e8b75cabe047ea4e9ed0eccd159cfdc67e9113326b8434e15ff82 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDhDOjExNjZFNjpEREY1RTA6MTI4RDg0Qjo2QTYyQjU1MCIsInZpc2l0b3JfaWQiOiI0MzA5MjYyNTM4MDgzODQxMzYwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= visitor-hmac 43ee52a5bfe42b32bd1ee19a5e522f7115488d19b20c4f9e5464e9014d14226d hovercard-subject-tag issue:403339155 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/29588/issue_layout twitter:image https://opengraph.githubassets.com/5a7378543ba8c19d29aa499d1cd23c476dbd5d6a665fd550a2ab093417c9452a/microsoft/TypeScript/issues/29588 twitter:card summary_large_image og:image https://opengraph.githubassets.com/5a7378543ba8c19d29aa499d1cd23c476dbd5d6a665fd550a2ab093417c9452a/microsoft/TypeScript/issues/29588 og:image:alt Type parameters constrained to any #29571 We've had a test since forever, but TypeScript provides absolutely zero validation on usages of type parameter constrained to any. const f = 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 2738d7125e864b55224a8bc40c72c220ca7d2c73f91a7bb8d69dffe9d35e997d 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 bf54af498459157b66a67136f992a68752cdbb54 ui-target full theme-color #1e2327 color-scheme light dark
URLs of crawlers that visited me.