Title: Recursive type literals · Issue #517 · microsoft/TypeScript · GitHub
Open Graph Title: Recursive type literals · Issue #517 · microsoft/TypeScript
X Title: Recursive type literals · Issue #517 · microsoft/TypeScript
Description: Introduction Currently, type literals are capable of representing any instantiated (non-generic) type except those that are recursive. This is because, as an anonymous type, they do not have a name with which to create this type. This pr...
Open Graph Description: Introduction Currently, type literals are capable of representing any instantiated (non-generic) type except those that are recursive. This is because, as an anonymous type, they do not have a name...
X Description: Introduction Currently, type literals are capable of representing any instantiated (non-generic) type except those that are recursive. This is because, as an anonymous type, they do not have a name...
Mail addresses
notifications@github.com
Opengraph URL: https://github.com/microsoft/TypeScript/issues/517
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recursive type literals","articleBody":"# Introduction\n\nCurrently, type literals are capable of representing any instantiated (non-generic) type except those that are recursive. This is because, as an anonymous type, they do not have a name with which to create this type.\n\nThis proposal covers recursive type literals. These type literals add the additional ability of the literal referring to itself. This has one main advantage: emitting .d.ts files for expressions typed by class expressions now have a \"flattened\" representations. As class expressions could easily have recursive components, we'd like to be able to emit a corresponding type representation into the .d.ts file without contaminating the namespace with additional fresh type names. \n# Design\n\n``` TypeScript\nvar x : \u003cNode> { next: Node; value: number; };\n```\n\nThe above acts similarly to this example:\n\n``` TypeScript\ninterface Node { next: Node; value: number; };\nvar x : Node; \n```\n\nwith one critical exception: in the first example the 'Node' name is **not** visible outside of the type literal.\n# Typechecking\n\nTypechecking of recursive type literals works just as recursive interfaces, with the exception (as mentioned above) that the name given to the recursive type literal is not visible in the lexical scope outside of the type literal. Otherwise, these expand and are compared for equality structurally just as interfaces.\n# Differences with other designs\n\nThis design differs from similar designs, named the 'self' type design where there is a specific keywords that the type can refer to its self. This proposal is strictly more expressive, albeit at the cost of some additional syntax. For example, embedded recursive types are possible:\n\n``` TypeScript\nvar x: \u003cNode> { up: \u003cParent>{ up: Parent; node: Node}; next: Node; value: number};\n```\n","author":{"url":"https://github.com/sophiajt","@type":"Person","name":"sophiajt"},"datePublished":"2014-08-22T23:37:10Z","url":"https://github.com/microsoft/TypeScript/issues/517"}
| 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:2459bd48-2e77-ad39-da39-352b5f3b7552 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B032:24A0A:179CEA7:1DBCCAB:6B016E4B |
| html-safe-nonce | 985267d54af7d62be53d17edd2ec06fff5aac349ae226dd6b9878835041ac765 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDMyOjI0QTBBOjE3OUNFQTc6MURCQ0NBQjo2QjAxNkU0QiIsInZpc2l0b3JfaWQiOiIzMjY3Njk4NTAxNzAxNjkzMDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8015936a07c6996bba648ae62606f09055fd8450da4b827b9485f0aa5a1c87f7 |
| hovercard-subject-tag | issue:40960217 |
| 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/517/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7195699b68fb84c13259af65036692e1e9d3388f3816ca0f9f5f54a0ae46cf54/microsoft/TypeScript/issues/517 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7195699b68fb84c13259af65036692e1e9d3388f3816ca0f9f5f54a0ae46cf54/microsoft/TypeScript/issues/517 |
| og:image:alt | Introduction Currently, type literals are capable of representing any instantiated (non-generic) type except those that are recursive. This is because, as an anonymous type, they do not have a name... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sophiajt |
| 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