{"action":"created","issue":{"url":"https://api.github.com/repos/scala-js/scala-js/issues/1824","labels_url":"https://api.github.com/repos/scala-js/scala-js/issues/1824/labels{/name}","comments_url":"https://api.github.com/repos/scala-js/scala-js/issues/1824/comments","events_url":"https://api.github.com/repos/scala-js/scala-js/issues/1824/events","html_url":"https://github.com/scala-js/scala-js/issues/1824","id":97090189,"number":1824,"title":"js.| union type","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scala-js/scala-js/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/scala-js/scala-js/milestones/32","html_url":"https://github.com/scala-js/scala-js/milestones/v0.6.5","labels_url":"https://api.github.com/repos/scala-js/scala-js/milestones/32/labels","id":1177428,"number":32,"title":"v0.6.5","description":"","creator":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":8,"state":"open","created_at":"2015-06-23T14:17:26Z","updated_at":"2015-07-28T08:59:36Z","due_on":null,"closed_at":null},"comments":21,"created_at":"2015-07-24T16:44:24Z","updated_at":"2015-07-28T09:03:51Z","closed_at":null,"body":"Edit: the original proposal was to name it `\\/`.\r\n\r\nIt would be worth thinking about a union type constructor for facade types. Similar to `js.UndefOr[+A]` in its construction, `js.|[+A, +B]`, or whatever it's called, would represent a value of type `A` or `B`. It would have zero API, though. The basic idea is the following:\r\n```scala\r\n@RawJSType // don't do this at home\r\nsealed trait |[+A, +B]\r\n\r\nobject \\/ {\r\n  implicit def fromA[A](a: A): A | Nothing = a.asInstanceOf[A | Nothing]\r\n  implicit def fromB[B](b: B): Nothing | B = b.asInstanceOf[Nothing | B]\r\n}\r\n```\r\nThen of course we need ways to transitively convert an `A`, a `B`, or a `C` to an `A | B | C`. This probably needs a bit of recursive implicit magic. Even trickier: convert `A | B`, `A | C` and `B | C` to `A | B | C` ^^"},"comment":{"url":"https://api.github.com/repos/scala-js/scala-js/issues/comments/125511220","html_url":"https://github.com/scala-js/scala-js/issues/1824#issuecomment-125511220","issue_url":"https://api.github.com/repos/scala-js/scala-js/issues/1824","id":125511220,"user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"created_at":"2015-07-28T09:03:51Z","updated_at":"2015-07-28T09:03:51Z","body":"Updated the title and description with `|`.\r\n\r\n@benjaminjackman TypeScript's `?` is different from our `UndefOr`. It indicates *optionality*, which is different from being either `A` or `undefined`. For example, they can use `?` with methods, or with parameters. Also, a missing field is not exactly the same as a field whose value is `undefined`, even if, often, the difference is not meaningful."}}