Skip to content

Incorrectly inferred type never for variables with strictNullChecks #9322

Closed
@e98cuenc

Description

@e98cuenc

TypeScript Version:

nightly (1.9.0-dev.20160623-1.0)

Code

let foo = [];
foo.push('x');

Expected behavior:

No errors, TypeScript should infer the type any[] for the variable foo.

Actual behavior:

tsc without any command line option behaves as expected, but when used with --strictNullChecks it emits the error:

foo.ts(2,10): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions