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

"Class constructor [XXX] cannot be invoked without 'new'" when using extend in ES6+ env #2101

Copy link
Copy link
Closed
@RexSkz

Description

@RexSkz
Issue body actions

Root Cause

The code https://github.com/immutable-js/immutable-js/blob/main/src/methods/merge.js#L27-L33 calls constructor without new. If the constructor is a class, it will throw this error.

Playground: https://immutable-js.com/play/#Y2xhc3MgTXlSZWNvcmQgZXh0ZW5kcyBSZWNvcmQoewogIC8vIGE6IDEKfSkge30KCnZhciBteVJlY29yZCA9IG5ldyBNeVJlY29yZCgpOwpteVJlY29yZC5tZXJnZSh7IGE6IDQgfSk7

Image

Workaround

Do not use the empty object as the parameter of Record.

- class MyRecord extends Record({}) {}
+ class MyRecord extends Record({ a: 1 }) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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.