Open
Description
Demo
playground demo
TypeScript source with nightly version 3.8.0-dev.20191224
type Address = {
city: string
}
type User = {
home: Address | undefined
work: Address | void
}
declare let u: User
u.home?.city
u.work?.city
JavaScript output the same for both "work" and "home" properties
"use strict";
var _a, _b;
(_a = u.work) === null || _a === void 0 ? void 0 : _a.city;
(_b = u.home) === null || _b === void 0 ? void 0 : _b.city;
Bug
If you run the code above, you will see that for u.home?.city
there are no errors.
But for u.work?.city
there is an error: