Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

__spreadArrays throws 'Cannot read property 'length' of null' when --strictNullChecks is off #33549

Copy link
Copy link
Closed
@KirillMetrik

Description

@KirillMetrik
Issue body actions

TypeScript Version: 3.6.3

Search Terms:
__spreadArrays, 3.6.3

Code
Make sure to run with --strictNullChecks off and compile for ES5!

function foo(b: number[]=null){
    const a=[1,2,...b];
    console.log(a);
}

foo();

Expected behavior:
No error should be produced by this code.

Actual behavior:

VM690:3 Uncaught TypeError: Cannot read property 'length' of null
    at __spreadArrays (eval at <anonymous> (main-0.js:1018), <anonymous>:3:82)
    at foo (eval at <anonymous> (main-0.js:1018), <anonymous>:11:13)
    at eval (eval at <anonymous> (main-0.js:1018), <anonymous>:14:1)
    at main-0.js:1018

Playground Link:
Error thrown in TS 3.6.3:
https://www.typescriptlang.org/play/?strictNullChecks=false&target=1#code/FAMwrgdgxgLglgewgAhAhAKARgLmRMAWywFMAnAbQF0BeAgG3oEoBvYZD5KJAZxmQCGNCgEYANACYxAOllYqAbnaduEHgnolp9BAHMMApkoC+wUOgxGgA

No error is thrown in TS 3.5.1:
https://www.typescriptlang.org/play/?strictNullChecks=false&target=1&ts=3.5.1#code/FAMwrgdgxgLglgewgAhAhAKARgLmRMAWywFMAnAbQF0BeAgG3oEoBvYZD5KJAZxmQCGNCgEYANACYxAOllYqAbnaduEHgnolp9BAHMMApkoC+wUOgxGgA

Related Issues:
none
The problem was probably introduced by this pull request: #31166

samal-rasmussenIllusionMH

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bugThe 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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.