Title: Spec doesn't mention variables witnessing themselves through type annotations · Issue #402 · microsoft/TypeScript · GitHub
Open Graph Title: Spec doesn't mention variables witnessing themselves through type annotations · Issue #402 · microsoft/TypeScript
X Title: Spec doesn't mention variables witnessing themselves through type annotations · Issue #402 · microsoft/TypeScript
Description: var x: typeof x; In section 5.1 Variable Statements we say: A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable is determined as follows: · If the decl...
Open Graph Description: var x: typeof x; In section 5.1 Variable Statements we say: A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable...
X Description: var x: typeof x; In section 5.1 Variable Statements we say: A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/402
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spec doesn't mention variables witnessing themselves through type annotations","articleBody":"``` ts\nvar x: typeof x;\n```\n\nIn section 5.1 Variable Statements we say:\n\n> A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable is determined as follows:\n> · If the declaration includes a type annotation, the stated type becomes the type of the variable. If an initializer is present, the initializer expression is contextually typed (section 4.19) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs.\n> · If the declaration includes an initializer but no type annotation, and if the initializer doesn’t directly or indirectly reference the variable, the widened type (section 3.9) of the initializer expression becomes the type of the property. If the initializer directly or indirectly references the variable, the type of the variable becomes the Any type.\n> · If the declaration includes neither a type annotation nor an initializer, the type of the variable becomes the Any type.\n\nThe second bullet covers cases like:\n\n``` ts\nvar x = x;\n```\n\nbut not cases like the initial example with no initializer. \n","author":{"url":"https://github.com/danquirk","@type":"Person","name":"danquirk"},"datePublished":"2014-08-08T01:01:23Z","url":"https://github.com/microsoft/TypeScript/issues/402"}
| 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:384f5553-dc8f-b954-5134-d956298b7d05 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E430:280A2E:1975E7:214087:6B016352 |
| html-safe-nonce | 8f0390b485b20dcb73f9f9015981557d992b872cbbbe6c8c684002a2510c81ec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDMwOjI4MEEyRToxOTc1RTc6MjE0MDg3OjZCMDE2MzUyIiwidmlzaXRvcl9pZCI6IjM4NDc4MDA2OTQ3ODIzODcwMjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bddc058383fbdb6f9008f60125146e346f0aa8b18239d6979701db38096e75a5 |
| hovercard-subject-tag | issue:39783073 |
| 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/402/issue_layout |
| twitter:image | https://opengraph.githubassets.com/92399fda57f5fc4ac8c9a11e543cba230b620ec2aaf42bc6ddb16e520e29c9e1/microsoft/TypeScript/issues/402 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/92399fda57f5fc4ac8c9a11e543cba230b620ec2aaf42bc6ddb16e520e29c9e1/microsoft/TypeScript/issues/402 |
| og:image:alt | var x: typeof x; In section 5.1 Variable Statements we say: A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danquirk |
| 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