Title: Intersect interfaces instead of union · Issue #33070 · microsoft/TypeScript · GitHub
Open Graph Title: Intersect interfaces instead of union · Issue #33070 · microsoft/TypeScript
X Title: Intersect interfaces instead of union · Issue #33070 · microsoft/TypeScript
Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union Code const someCondition = true interface Func1Options { name: string } interface Func2Options { age: n...
Open Graph Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union Code const someCondition = true interface Func1Options { name: ...
X Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union Code const someCondition = true interface Func1Options { name: ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/33070
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Intersect interfaces instead of union","articleBody":"**TypeScript Version:** 3.4.0-dev.201xxxxx\r\n\r\n**Search Terms:** Intersection interfaces, Ternary operator, Intersect interfaces instead of union\r\n\r\n**Code**\r\n\r\n```ts\r\nconst someCondition = true\r\n\r\ninterface Func1Options { name: string }\r\ninterface Func2Options { age: number }\r\n\r\nfunction Func1 (options: Func1Options) { console.log(options) }\r\nfunction Func2 (options: Func2Options) { console.log(options) }\r\n\r\nconst selectedFunc = someCondition \r\n ? Func1\r\n : Func2\r\n\r\nselectedFunc({\r\n age: 20,\r\n name: 'Alastar'\r\n})\r\n\r\n```\r\n\r\n**Expected behavior:**\r\n`selectedFunc` accepts `Func1Options`\r\n\r\n**Actual behavior:**\r\n`selectedFunc` accepts `Func1Options & Func2Options`\r\n\r\n**Playground Link:** [Playground](http://www.typescriptlang.org/play/#code/MYewdgzgLgBBIFsCmBhcATAllT4YF4YoAnAVyQCgLMwoliAzAQ2CRgDFSxgBGAeQAOOcBBgBvGGCbIAXHBI0A5jAC+1WvWasOXYACZBwyOJhNFSOWFIIARvVVUGuozu48YAChBDckOZzdDXwgAShNQSBAAGyQAOiiQRS8fETC1J24XAP1PbyMIf10DFMgwiQj4GPjE5Py0qgrYCCQY4Dp0bII4RFQMbF8YChgAfldeIcLuPSpm1vbsjzEhmBWzCxg9AAYAGmWVqVkYAHIAQSimaCZiI4oVEIogA)","author":{"url":"https://github.com/Rukomoynikov","@type":"Person","name":"Rukomoynikov"},"datePublished":"2019-08-24T11:58:58Z","url":"https://github.com/microsoft/TypeScript/issues/33070"}
| 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:5aa9779c-5695-dba7-e62e-4fa0cc4a1de7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A686:305B07:8D4D5E:BCC88F:6B00E181 |
| html-safe-nonce | 7815fe18b42ea288c7dd42ed35d5ff13d195622ae69018c5c49bcd2c0b0a3cc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjg2OjMwNUIwNzo4RDRENUU6QkNDODhGOjZCMDBFMTgxIiwidmlzaXRvcl9pZCI6IjY0NzEyMjc3OTc5MDkwNzAyMDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1593a281515ea44dcbed3aeb0a2fea05a9e171451b36faffd8f6c4f85d45d2a3 |
| hovercard-subject-tag | issue:484809851 |
| 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/33070/issue_layout |
| twitter:image | https://opengraph.githubassets.com/01d9567ab55f16f811cd76ff3c8a32d89a5ce3b03312ecbe924d9e73c2b8f549/microsoft/TypeScript/issues/33070 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/01d9567ab55f16f811cd76ff3c8a32d89a5ce3b03312ecbe924d9e73c2b8f549/microsoft/TypeScript/issues/33070 |
| og:image:alt | TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Intersection interfaces, Ternary operator, Intersect interfaces instead of union Code const someCondition = true interface Func1Options { name: ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Rukomoynikov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width