Skip to content

Rest parameter fails to compile with strictNullChecks and target es6  #8430

Closed
@seanchas116

Description

@seanchas116

TypeScript Version:

1.9.0-dev.20160502

Code

const xs = [1,2,3];
const ys = [4,5];
xs.push(...ys);

Compiled with tsc --target es6 --strictNullChecks test.ts

Expected behavior:

Compile without errors (without --target es6 option, the code compiles successfully)

Actual behavior:

Errors are emitted:

test.ts(3,9): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.

Seems like values are treated nullable. (similar to #8357)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions