Title: Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/TypeScript · GitHub
Open Graph Title: Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/TypeScript
X Title: Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/Type...
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/Type...
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Operator to ensure an expression is contextually typed by, and satisfies, some type","articleBody":"Sometimes it's necessary (e.g. for guiding type inference, for ensuring sub-expression conforms to an interface, or for clarity) to change the static type of an expression. Currently TypeScript has the `as` (aka `\u003c>`) operator for that, but it's dangerous, as it also allows down-casting. It would be nice if there was another operator for implicit conversions only (type compatibility). I think this operator should be recommended in most cases instead of `as`.\n\nThis operator can be implemented as a generic function, but as it shouldn't have any run-time effect, it would be better if it was incorporated into the language.\n\n``` typescript\nfunction asType\u003cT>(value: T) {\n return value;\n};\n```\n\nEDIT: Due to parameter bivariance, this function is _not_ equivalent to the proposed operator, because asType allows downcasts too.\n","author":{"url":"https://github.com/magnushiie","@type":"Person","name":"magnushiie"},"datePublished":"2016-03-11T13:19:53Z","url":"https://github.com/microsoft/TypeScript/issues/7481"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:8765431b-450d-8d3d-e43c-2096ddaace93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB1C:4D9F2:9CF95:CCB6B:6B018295 |
| html-safe-nonce | e1f4df9599cb884cc83450ddce443ea29c914c4ba8c6d5b66898027d57664ef5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjFDOjREOUYyOjlDRjk1OkNDQjZCOjZCMDE4Mjk1IiwidmlzaXRvcl9pZCI6IjM5OTgzNDY2NDcxOTYyMzg0ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6c2aba3119bbf2e0dabfc21cd6765f440d728337973e30458ec92ad310aee80b |
| hovercard-subject-tag | repository:20929025 |
| 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/microsoft/TypeScript/issues/7481 |
| twitter:image | https://opengraph.githubassets.com/47cde802d3847ff7ce61448bd4f8c3272d012c9a3f2b9085b71a67530bf7bbd6/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/47cde802d3847ff7ce61448bd4f8c3272d012c9a3f2b9085b71a67530bf7bbd6/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Operator to ensure an expression is contextually typed by, and satisfies, some type · Issue #7481 · microsoft/Type... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-cache |
| 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