Title: Type inference for exact strings · Issue #16276 · microsoft/TypeScript · GitHub
Open Graph Title: Type inference for exact strings · Issue #16276 · microsoft/TypeScript
X Title: Type inference for exact strings · Issue #16276 · microsoft/TypeScript
Description: TypeScript Version: 2.2.2 Code interface Css { position: 'absolute' | 'relative'; } function style(rules: Css) { } const rules = { position: 'absolute' }; style(rules); style({ position: 'absolute' }); Expected behavior: There should be ...
Open Graph Description: TypeScript Version: 2.2.2 Code interface Css { position: 'absolute' | 'relative'; } function style(rules: Css) { } const rules = { position: 'absolute' }; style(rules); style({ position: 'absolute'...
X Description: TypeScript Version: 2.2.2 Code interface Css { position: 'absolute' | 'relative'; } function style(rules: Css) { } const rules = { position: 'absolute' }; style(rules); styl...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/16276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference for exact strings","articleBody":"**TypeScript Version:** 2.2.2\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface Css {\r\n position: 'absolute' | 'relative';\r\n}\r\nfunction style(rules: Css) { }\r\n\r\nconst rules = { position: 'absolute' };\r\nstyle(rules);\r\nstyle({ position: 'absolute' });\r\n```\r\n\r\n**Expected behavior:**\r\nThere should be no type issues.\r\n\r\n**Actual behavior:**\r\n`style(rules)` yields\r\n\r\n> `Argument of type '{ position: string; }' is not assignable to parameter of type 'Css'`\r\n> `Types of property 'position' are incompatible`\r\n\r\nUsing `style({position: 'absolute'})` works fine.","author":{"url":"https://github.com/ajcrites","@type":"Person","name":"ajcrites"},"datePublished":"2017-06-05T22:41:56Z","url":"https://github.com/microsoft/TypeScript/issues/16276"}
| 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:4c44711b-388f-637e-bbd5-a3caaaeae08c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E012:317608:A35A71:D08723:6B00F19B |
| html-safe-nonce | e7f93d75e55f2c3cd0ff6b6426ed0b76576e5e6e10322fc32a7166c60ee45c2c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDEyOjMxNzYwODpBMzVBNzE6RDA4NzIzOjZCMDBGMTlCIiwidmlzaXRvcl9pZCI6IjY0MjYzMjExNjE3NTUzNTc1OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7e75c40a08e8f55990668e92f1a07658066031e81efc54b90c7c715fad19762d |
| hovercard-subject-tag | issue:233731372 |
| 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/16276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d60ea73dd8d5b20368d5a3b37c4baaef4fb02862ecd5fd6bf9be44712002c784/microsoft/TypeScript/issues/16276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d60ea73dd8d5b20368d5a3b37c4baaef4fb02862ecd5fd6bf9be44712002c784/microsoft/TypeScript/issues/16276 |
| og:image:alt | TypeScript Version: 2.2.2 Code interface Css { position: 'absolute' | 'relative'; } function style(rules: Css) { } const rules = { position: 'absolute' }; style(rules); style({ position: 'absolute'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ajcrites |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width