8000 asImmutable does not return itself when collection is empty · Issue #1413 · immutable-js/immutable-js · GitHub
[go: up one dir, main page]

Skip to content
asImmutable does not return itself when collection is empty #1413
Closed
@myitcv

Description

@myitcv

Using v4.0.0-rc.9

What happened

The documentation for asImmutable states:

Because it [asImmutable()] applies to mutable collections, this operation is mutable and returns itself.

But the following Typescript example shows this not to be the case where a collection (list in this case) is empty:

let l1 = Immutable.List<number>().asMutable();
let l2 = l1.asMutable();

expect(l2).toBe(l1);

let l3 = l2.asImmutable();

expect(l3).toBe(l2); // FAILS

In my opinion asImmutable should, per the docs, always return itself. But I raise this issue for discussion on whether the implementation or docs need to change.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0