Skip to content

Object is incorrectly typed as 'possibly null' after import without ability to check #16408

Closed

Description

TypeScript Version: 2.3.4

Code

// strictNull1.ts file
let x = true;
export const test = x
    ? { y: () => null }
    : null;

//strictNull2
import {test} from './strictNull1';
if (test) {
    test && test.y(); //<-- Object is possibly 'null' even though I checked!
}

Expected behavior:
No error

Actual behavior:
Object is possibly 'null'

Activity

  1. ghost added
    FixedA PR has been merged for this issue
    on Jun 20, 2017
  2. ghost removed
    Needs InvestigationThis issue needs a team member to investigate its status.
    on Jun 20, 2017
  3. ghost added
    DuplicateAn existing issue was already created
    on Jun 20, 2017
  4. ghost closed this as completedin #16658on Jul 10, 2017
  5. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDuplicateAn existing issue was already createdFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions