Title: Default to single literal type whenever value is omitted · Issue #20500 · microsoft/TypeScript · GitHub
Open Graph Title: Default to single literal type whenever value is omitted · Issue #20500 · microsoft/TypeScript
X Title: Default to single literal type whenever value is omitted · Issue #20500 · microsoft/TypeScript
Description: Consider the interface: interface xyz { num: 1 str: "ok" } Currently the following snippet generates a type error: let foo: xyz = {} My proposal is the whenever a variable is declared to contain only one possible value, that value should...
Open Graph Description: Consider the interface: interface xyz { num: 1 str: "ok" } Currently the following snippet generates a type error: let foo: xyz = {} My proposal is the whenever a variable is declared to contain on...
X Description: Consider the interface: interface xyz { num: 1 str: "ok" } Currently the following snippet generates a type error: let foo: xyz = {} My proposal is the whenever a variable is declared to ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/20500
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Default to single literal type whenever value is omitted","articleBody":"Consider the interface:\r\n```\r\ninterface xyz {\r\n num: 1\r\n str: \"ok\"\r\n}\r\n\r\n```\r\nCurrently the following snippet generates a type error:\r\n`let foo: xyz = {}`\r\n\r\nMy proposal is the whenever a variable is declared to contain only one possible value, that value should be assumed whenever the variable's value is not specified. So, the above snippet would then not generate an error, but this would:\r\n`let foo: xyz = { num: 2 }`\r\n\r\nThis proposed feature will make it easier to write clearer and simpler TypeScript code. ","author":{"url":"https://github.com/agyemanjp","@type":"Person","name":"agyemanjp"},"datePublished":"2017-12-06T13:16:23Z","url":"https://github.com/microsoft/TypeScript/issues/20500"}
| 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:93a12f26-7bc4-730b-9d6d-e4542fc7c620 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA44:27D3AD:5C2212:76CA80:6B00DC87 |
| html-safe-nonce | cc470621d7a69ebd53e6256cd6347282d652d3b5bb732967a8e2bd3df7bfe72f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTQ0OjI3RDNBRDo1QzIyMTI6NzZDQTgwOjZCMDBEQzg3IiwidmlzaXRvcl9pZCI6IjgxNDM2ODkzOTQ0MTEzMzA2OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 33df585a99eda261c9f8fd9bcaa0c9267ed2b32dab5310db01c8c1c0c0190cb0 |
| hovercard-subject-tag | issue:279749109 |
| 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/20500/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e339627296e8359b9c36534560b743e9a7d5e0548d381f49f0f73d53bbf1d422/microsoft/TypeScript/issues/20500 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e339627296e8359b9c36534560b743e9a7d5e0548d381f49f0f73d53bbf1d422/microsoft/TypeScript/issues/20500 |
| og:image:alt | Consider the interface: interface xyz { num: 1 str: "ok" } Currently the following snippet generates a type error: let foo: xyz = {} My proposal is the whenever a variable is declared to contain on... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | agyemanjp |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width