-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Something ElseFallback label when we just can't figure anything else outFallback label when we just can't figure anything else out
Milestone
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?.cityJavaScript 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:
Error: Property 'city' does not exist on type 'void | Address'
Expectation
Optional chaining works for both 'undefined' and 'void' types the same way.
Raiondesu, johan-gorter, sharno, marafat, macrozone and 16 morewojpawlik
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Something ElseFallback label when we just can't figure anything else outFallback label when we just can't figure anything else out