Title: Union Types And Strings · Issue #9489 · microsoft/TypeScript · GitHub
Open Graph Title: Union Types And Strings · Issue #9489 · microsoft/TypeScript
X Title: Union Types And Strings · Issue #9489 · microsoft/TypeScript
Description: TypeScript Version: 2.0.0-dev.20160702 Code const t = (a: "a"|"b") => a; const b = "a"; t(b); Expected behavior: No errors Actual behavior: src/index.tsx(3,3): error TS2345: Argument of type 'string' is not assignable to parameter of typ...
Open Graph Description: TypeScript Version: 2.0.0-dev.20160702 Code const t = (a: "a"|"b") => a; const b = "a"; t(b); Expected behavior: No errors Actual behavior: src/index.tsx(3,3): error TS2345: Argument of type 'strin...
X Description: TypeScript Version: 2.0.0-dev.20160702 Code const t = (a: "a"|"b") => a; const b = "a"; t(b); Expected behavior: No errors Actual behavior: src/index.tsx(3,3): erro...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9489
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Union Types And Strings","articleBody":"**TypeScript Version:** 2.0.0-dev.20160702\n\n**Code**\n\n``` js\nconst t = (a: \"a\"|\"b\") => a;\nconst b = \"a\";\nt(b);\n```\n\n**Expected behavior:**\nNo errors\n\n**Actual behavior:** \n\n``` bash\nsrc/index.tsx(3,3): error TS2345: Argument of type 'string' is not assignable to parameter of type '\"a\" | \"b\"'.\n```\n\nThis is just a toy example, and can be fixed with enums or other approaches.\nI'm actually having this issue, where tsc gives me a lot of error in the CSS.\nFor example\n\n``` bash\nsrc/index.tsx(33,13): error TS2322: Type '{ flex: number; justifyContent: string; alignItems: string; backgroundColor: string; }' is not assignable to type 'ViewStyle'.\n Types of property 'alignItems' are incompatible.\n Type 'string' is not assignable to type '\"flex-start\" | \"flex-end\" | \"center\" | \"stretch\"'.\n```\n\nPlease also note that\n\n``` js\nt(\"a\");\n```\n\ndoesn't give any error, but I can't really use it to solve the react issue.\n\nI'm not sure if there is another issue related to the same problem. I tried to search in the opened issues but I haven't found anything.\n","author":{"url":"https://github.com/bolismauro","@type":"Person","name":"bolismauro"},"datePublished":"2016-07-02T10:31:23Z","url":"https://github.com/microsoft/TypeScript/issues/9489"}
| 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:9a6d7ab5-8c16-aca8-bbdc-6fad208a398a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9660:260731:BB727:FA494:6AFBDB17 |
| html-safe-nonce | c3a0ee041fbdb471705ed11eca0bbffa262d4e8851b21f2d9200279aa30b5a68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjYwOjI2MDczMTpCQjcyNzpGQTQ5NDo2QUZCREIxNyIsInZpc2l0b3JfaWQiOiI2NjE0NzcxNDg0NzUxMjg5MTExIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cfc09cbe26732f8aaeac741c7b6499f6f17b0fa56d64bfe3c29ef4b41a478068 |
| hovercard-subject-tag | issue:163512565 |
| 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/9489/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e382a25785161e994175965d06033abb025c09703cde5b1bb1da0b3b71ec63f6/microsoft/TypeScript/issues/9489 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e382a25785161e994175965d06033abb025c09703cde5b1bb1da0b3b71ec63f6/microsoft/TypeScript/issues/9489 |
| og:image:alt | TypeScript Version: 2.0.0-dev.20160702 Code const t = (a: "a"|"b") => a; const b = "a"; t(b); Expected behavior: No errors Actual behavior: src/index.tsx(3,3): error TS2345: Argument of type 'strin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bolismauro |
| 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