Closed
Description
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
2.1.1
Code
type Option = 'a' | { result: number }
type Value = { option: Option }
function do1(value: Value) {
if (value.option != 'a') {
const { result } = value.option
}
}
function do2(value: Value) {
if (value.option != 'a') {
const { option: { result } } = value // [ts] Type 'Option' has no property 'result' and no string index signature.
}
}
Expected behavior:
do2
works as do1
, type of value.option
is determined
Actual behavior:
do2
works differently from do1
, type of value.option
is not determined