Created
October 8, 2019 23:20
-
-
Save vogler/d80e7045b008c23347650b82b36d133a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type a = { id: number, name: string, foo: string } | |
type b = { id: string, name: string, bar: string } | |
type c = a | b | |
type d = a & b | |
type id = d['id'] // number & string = never (bot) | |
const va: a = {id: 1, name: 'ha', foo: 'foo'} | |
const vb: b = {id: '1', name: 'ha', bar: 'bar'} | |
const vc1: c = va | |
const vc2: c = vb | |
const vc3/*: c*/ = { ...va, ...vb } | |
const vd: d = vc3 // error message could be better; there is no value satisfying d since id: never |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment