Title: String Literal Type does not work · Issue #20271 · microsoft/TypeScript · GitHub
Open Graph Title: String Literal Type does not work · Issue #20271 · microsoft/TypeScript
X Title: String Literal Type does not work · Issue #20271 · microsoft/TypeScript
Description: TypeScript Version: 2.7.0-dev.201xxxxx Code // A *self-contained* demonstration of the problem follows... // Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. interface Typ...
Open Graph Description: TypeScript Version: 2.7.0-dev.201xxxxx Code // A *self-contained* demonstration of the problem follows... // Test this by running `tsc` on the command-line, rather than through another build tool s...
X Description: TypeScript Version: 2.7.0-dev.201xxxxx Code // A *self-contained* demonstration of the problem follows... // Test this by running `tsc` on the command-line, rather than through another build tool s...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/20271
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"String Literal Type does not work","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.7.0-dev.201xxxxx\r\n\r\n**Code**\r\n\r\n```ts\r\n// A *self-contained* demonstration of the problem follows...\r\n// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.\r\ninterface TypeA {\r\n test: \"test1\" | \"test2\" | \"test3\"\r\n}\r\n\r\nfunction fn(param: TypeA) {\r\n\r\n}\r\n\r\n// Check pass\r\nfn({\r\n test: \"test1\"\r\n});\r\n\r\n// The same object, but passed by object reference\r\nlet obj = {\r\n test: \"test1\"\r\n};\r\n\r\n/**\r\n * Error:(26, 4) TS2345: Argument of type '{ test: string; }' is not assignable to parameter of type 'TypeA'.\r\n * Types of property 'test' are incompatible.\r\n * Type 'string' is not assignable to type '\"test1\" | \"test2\" | \"test3\"'.\r\n */\r\nfn(obj);\r\n\r\n```\r\n\r\n**Expected behavior:**\r\nCheck pass\r\n**Actual behavior:**\r\nI get a TS2345","author":{"url":"https://github.com/sevenryze","@type":"Person","name":"sevenryze"},"datePublished":"2017-11-26T15:45:15Z","url":"https://github.com/microsoft/TypeScript/issues/20271"}
| 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:9184c7b2-56f9-3b21-f423-08209e685baa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B98:FA3FB:CF1FC:123598:6AFBDA93 |
| html-safe-nonce | 33d663d696f154a5a058f342964bdc327907f8268d54567782992a6c6b93aaf5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Qjk4OkZBM0ZCOkNGMUZDOjEyMzU5ODo2QUZCREE5MyIsInZpc2l0b3JfaWQiOiI4MTg5NDA3Njc2MzA0NDQ4MTQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | eb6b2c34a792312b2000cfbb422fc782f6e1c3cae00ce6a7227186d2e1a978cd |
| hovercard-subject-tag | issue:276834021 |
| 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/20271/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b4b13ac56384e9d2a338f2aba5610cdc932fc0a210e8492f28a5f8137e14cb88/microsoft/TypeScript/issues/20271 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b4b13ac56384e9d2a338f2aba5610cdc932fc0a210e8492f28a5f8137e14cb88/microsoft/TypeScript/issues/20271 |
| og:image:alt | TypeScript Version: 2.7.0-dev.201xxxxx Code // A *self-contained* demonstration of the problem follows... // Test this by running `tsc` on the command-line, rather than through another build tool s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sevenryze |
| hostname | github.com |
| expected-hostname | github.com |
| None | 18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07 |
| 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 | 820be804f18e1ef3940bd74a00d41d73d02e2b91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width