Skip to content

object possibly null in short circuit evaluation #10087

Closed
@nippur72

Description

@nippur72

An if with condition that contains an explicited short-circuit evaluation cause null check to fail:

   const m:string|null = "a";

   if(m===null || (m.length>50)) throw "";
   m.length;  // ok

   if(m===null || (m!==null && m.length>50)) throw "";
   m.length;  // fails with: Object is possibly 'null'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions