Skip to content

ObjectConstructor.assign #35621

@TrejGun

Description

@TrejGun

TypeScript Version: 3.7.2

Search Terms:
ObjectConstructor, Object, assign, target, null

Code

Object.assign(null, {a:1})

this works because

    assign<T, U>(target: T, source: U): T & U;

but T can't be null

Expected behavior:
type error is risen ts and reported by typescript-eslint

Actual behavior:
type error in js

TypeError: Cannot convert undefined or null to object
    at Function.assign (<anonymous>)

Playground Link:
http://www.typescriptlang.org/play/?ssl=1&ssc=26&pln=1&pc=21#code/PIIwVgpgxgLgdAQwM5IJYHMB2AKTBXAGwIBoACAbwQC4BGAXwEog

Related Issues:
#3429

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions