Skip to content

Improve asImmutable() docs #1415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions type-definitions/Immutable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1280,14 +1280,18 @@ declare module Immutable {
* a mutable copy of this collection. Mutable copies *always* return `this`,
* and thus shouldn't be used for equality. Your function should never return
* a mutable copy of a collection, only use it internally to create a new
* collection. If possible, use `withMutations` as it provides an easier to
* use API.
* collection.
*
* If possible, use `withMutations` to work with temporary mutable copies as
* it provides an easier to use API and considers many common optimizations.
*
* Note: if the collection is already mutable, `asMutable` returns itself.
*
* Note: Not all methods can be used on a mutable collection or within
* `withMutations`! Read the documentation for each method to see if it
* is safe to use in `withMutations`.
*
* @see `Map#asImmutable`
*/
asMutable(): this;

Expand All @@ -1301,8 +1305,15 @@ declare module Immutable {

/**
* The yin to `asMutable`'s yang. Because it applies to mutable collections,
* this operation is *mutable* and returns itself. Once performed, the mutable
* copy has become immutable and can be safely returned from a function.
* this operation is *mutable* and may return itself (though may not
* return itself, i.e. if the result is an empty collection). Once
* performed, the original mutable copy must no longer be mutated since it
* may be the immutable result.
*
* If possible, use `withMutations` to work with temporary mutable copies as
* it provides an easier to use API and considers many common optimizations.
*
* @see `Map#asMutable`
*/
asImmutable(): this;

Expand Down