-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.8.0-dev.20180308
Search Terms:
typeof union parameter undefined.
Code
declare var value: string | Date;
if (typeof value.now /*error!*/ !== "undefined") {}Expected behavior:
No error and appropriate type narrowing.
Actual behavior:
[ts]
Property 'now' does not exist on type 'string | Date'.
Property 'now' does not exist on type 'string'.
NOTE
I don't like having to make a new function to properly narrow types for every union I create, is there another way around this (like manually overriding the variable's type within the scope of a code block without declaring a new variable?).
niieani
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript