Skip to content

Releases: immutable-js/immutable-js

v5.0.0-beta.5

26 Jan 20:00
Compare
Choose a tag to compare
v5.0.0-beta.5 Pre-release
Pre-release

What's Changed

Merge fixes from v4.3.5

v4.3.5

26 Jan 10:34
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.3.4...v4.3.5

5.0.0-beta.4

28 Aug 12:52
Compare
Choose a tag to compare
5.0.0-beta.4 Pre-release
Pre-release

Revert tree-shaking possibility as it does break. Moreover, as nearly every collection type can be converted to another collection (Map().toList() for example), so nearly no code was removed.

I think that if we want to implement this, we might need to rethink this functionality.

5.0.0-beta.2

25 Aug 13:53
Compare
Choose a tag to compare
5.0.0-beta.2 Pre-release
Pre-release

Merge main branch into 5.x for 4.3.4 fixes.

4.3.4

25 Aug 13:40
Compare
Choose a tag to compare

What's Changed

  • Rollback toJS type due to circular reference error by @jdeniau in #1958

Full Changelog: v4.3.3...v4.3.4

5.0.0-beta.1

24 Aug 16:06
Compare
Choose a tag to compare
5.0.0-beta.1 Pre-release
Pre-release

[Minor BC break] Reducing file size / tree shaking

Immutable does not export a default object containing all it's API anymore.
It changes the output of your JS file if you use a bundler that supports tree-shaking (all modern bundler do).
As a drawback, you can not immport Immutable directly:

- import Immutable from 'immutable';
+ import { List, Map } from 'immutable';

- const l = Immutable.List([Immutable.Map({ a: 'A' })]);
+ const l = List([Map({ a: 'A' })]);

If you want the non-recommanded, but shorter migration path, you can do this:

- import Immutable from 'immutable';
+ import * as Immutable from 'immutable';

  const l = Immutable.List([Immutable.Map({ a: 'A' })]);

[TypeScript Break] Improve TypeScript definition for Map

If you do not use TypeScript, then this change does not impact you : no runtime change here.
But if you use Map with TypeScript, this is a HUGE change !

Imagine the following code

const m = Map({ length: 3, 1: 'one' });

This was previously typed as Map<string, string | number>

and return type of m.get('length') or m.get('inexistant') was typed as string | number | undefined.

This made Map really unusable with TypeScript.

Now the Map is typed like this:

MapOf<{
    length: number;
    1: string;
}>

and the return type of m.get('length') is typed as number.

The return of m.get('inexistant') throw the TypeScript error:

Argument of type '"inexistant"' is not assignable to parameter of type '1 | "length"

If you want to keep the old definition

This is a minor BC for TS users, so if you want to keep the old definition, you can declare you Map like this:

const m = Map<string, string | number>({ length: 3, 1: 'one' });

If you need to type the Map with a larger definition

You might want to declare a wider definition, you can type your Map like this:

type MyMapType = {
  length: number;
  1: string | null;
  optionalProperty?: string;
};
const m = Map<MyMapType>({ length: 3, 1: 'one' });

Keep in mind that the MapOf will try to be consistant with the simple TypeScript object, so you can not do this:

Map({ a: 'a' }).set('b', 'b');
Map({ a: 'a' }).delete('a');

Like a simple object, it will only work if the type is forced:

Map<{ a: string; b?: string }>({ a: 'a' }).set('b', 'b'); // b is forced in type and optional
Map<{ a?: string }>({ a: 'a' }).delete('a'); // you can only delete an optional key

Are all Map methods implemented ?

For now, only get, getIn, set, update, delete, remove, toJS, toJSON methods are implemented. All other methods will fallback to the basic Map definition. Other method definition will be added later, but as some might be really complex, we prefer the progressive enhancement on the most used functions.

v4.3.3

23 Aug 09:59
2306527
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.3.1...v4.3.3

v4.3.2

03 Aug 06:55
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.3.1...v4.3.2

v4.3.1

11 Jul 20:54
a4eaaf0
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.3.0...v4.3.1

v4.3.0

10 Mar 15:18
41fcd04
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.2.4...v4.3.0