Closed
Description
type A = {tag: 'a', a: 1} | {tag: 'b', b: 1}
type B = A & {tag: 'b'}
declare var b : B
let z = b.b // Error: Property 'b' does not exist on type 'B'
Expected behavior: b
(type B
) only possible value for tag
property is 'b'
, so it must be discriminated to {tag : 'b' , 'b' : 1}
without needing to enclose it in a if(b.tag == 'b')
type guard
Actual behavior: b
(type B
) is not discriminated, needs type guards just like plain A
TypeScript Version: 2.0.6