Title: refinement types · Issue #7599 · microsoft/TypeScript · GitHub
Open Graph Title: refinement types · Issue #7599 · microsoft/TypeScript
X Title: refinement types · Issue #7599 · microsoft/TypeScript
Description: This is a further development of the idea of tag types. There are situations where being able to encode a certain predicate about a given value using its type is tremendously helpful. Let's imagine that we have a number. In order to proc...
Open Graph Description: This is a further development of the idea of tag types. There are situations where being able to encode a certain predicate about a given value using its type is tremendously helpful. Let's imagine...
X Description: This is a further development of the idea of tag types. There are situations where being able to encode a certain predicate about a given value using its type is tremendously helpful. Let's ima...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7599
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"refinement types","articleBody":"This is a further development of the idea of [tag types](https://github.com/Microsoft/TypeScript/issues/4895).\n\nThere are situations where being able to encode a certain predicate about a given value using its type is tremendously helpful.\n\nLet's imagine that we have a number. In order to proceed with it we need to assert that it is greater than 0. This assertion doesn't come for free, because it takes some processor time to get evaluated. Since numbers are immutable this assertion only needs to be evaluated once and will hold true from then on without having to be reevaluated. But due to having no way to attach this knowledge to the number value we:\n- either need to play safe and reevaluate it every time immediately before using \n- or take our chances trying to trace it through the code from the place where it was asserted keeping the result of the assertion in mind and hoping not to break things during the next refactoring\n\nBeing able to attach additional knowledge to the type of a value in form of predicate that is guaranteed to hold true as long as the value doesn't change is what is called **refinement types**.\n\n@ahejlsberg, what are the chances of seeing the refinement types in TypeScript one day?\n\nReferences: \n- Refinement types: https://en.wikipedia.org/wiki/Refinement_(computing)\n- Pre/post conditions, Hoare logic: https://en.wikipedia.org/wiki/Hoare_logic\n- Design by contract: https://en.wikipedia.org/wiki/Design_by_contract\n","author":{"url":"https://github.com/zpdDG4gta8XKpMCd","@type":"Person","name":"zpdDG4gta8XKpMCd"},"datePublished":"2016-03-20T11:07:06Z","url":"https://github.com/microsoft/TypeScript/issues/7599"}
| 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:04973273-264d-8da4-e097-0944c08f88b5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C8C:60624:141940:1CD4D1:6AFBFB66 |
| html-safe-nonce | 1ea65b7e46a0ad06f6650b5721eb28e3bd485058161312677fce9dbdc6218aec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzhDOjYwNjI0OjE0MTk0MDoxQ0Q0RDE6NkFGQkZCNjYiLCJ2aXNpdG9yX2lkIjoiMTI0NDkxNTcwMTk0Njc2NTgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c592860a7627aeb71dcc2bf4448f1665c85612b3b0b62a8a34afdf339c2c0670 |
| hovercard-subject-tag | issue:142151884 |
| 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/7599/issue_layout |
| twitter:image | https://opengraph.githubassets.com/02941f99034009db036d624beea31eaa399ee9ed407fb0e6208829ab88c5766b/microsoft/TypeScript/issues/7599 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/02941f99034009db036d624beea31eaa399ee9ed407fb0e6208829ab88c5766b/microsoft/TypeScript/issues/7599 |
| og:image:alt | This is a further development of the idea of tag types. There are situations where being able to encode a certain predicate about a given value using its type is tremendously helpful. Let's imagine... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zpdDG4gta8XKpMCd |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| 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 | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width