Skip to content

Remove deprecated packages #1982

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
Jan 31, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ Dates are formatted as YYYY-MM-DD.

## Unreleased

- [BREAKING] Remove deprecated methods:

- `Map.of('k', 'v')`: use `Map([ [ 'k', 'v' ] ])` or `Map({ k: 'v' })`
- `Collection.isIterable`: use `isIterable` directly
- `Collection.isKeyed`: use `isKeyed` directly
- `Collection.isIndexed`: use `isIndexed` directly
- `Collection.isAssociative`: use `isAssociative` directly
- `Collection.isOrdered`: use `isOrdered` directly

## [5.0.0-beta.5]

- Change Range function: force start and end values to be defined [#1967](https://github.com/immutable-js/immutable-js/pull/1967) by [@jdeniau](https://github.com/jdeniau)
- [internal] Upgrade to rollup 3.x [#1965](https://github.com/immutable-js/immutable-js/pull/1965) by [@jdeniau](https://github.com/jdeniau)
- [internal] upgrade tooling (TS, eslint) and documentation packages: #1971, #1972, #1973, #1974, #1975, #1976, #1977, #1978, #1979, #1980, #1981

## [5.0.0-beta.4]

Expand Down
15 changes: 0 additions & 15 deletions __tests__/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@ describe('Map', () => {
expect(m.toJS()).toEqual({ length: 3, 1: 'one' });
});

it('accepts flattened pairs via of()', () => {
// @ts-expect-error Map.of type is <unknown, unknown>, but function is deprecated
const m: Map<number, string> = Map.of(1, 'a', 2, 'b', 3, 'c');
expect(m.size).toBe(3);
expect(m.get(1)).toBe('a');
expect(m.get(2)).toBe('b');
expect(m.get(3)).toBe('c');
});

it('does not accept mismatched flattened pairs via of()', () => {
expect(() => {
Map.of(1, 2, 3);
}).toThrow('Missing value for key: 3');
});

it('converts back to JS object', () => {
const m = Map({ a: 'A', b: 'B', c: 'C' });
expect(m.toObject()).toEqual({ a: 'A', b: 'B', c: 'C' });
Expand Down
10 changes: 1 addition & 9 deletions src/CollectionImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {
IndexedCollection,
SetCollection,
} from './Collection';
import { isCollection, IS_COLLECTION_SYMBOL } from './predicates/isCollection';
import { isAssociative } from './predicates/isAssociative';
import { IS_COLLECTION_SYMBOL } from './predicates/isCollection';
import { isKeyed, IS_KEYED_SYMBOL } from './predicates/isKeyed';
import { isIndexed, IS_INDEXED_SYMBOL } from './predicates/isIndexed';
import { isOrdered, IS_ORDERED_SYMBOL } from './predicates/isOrdered';
Expand Down Expand Up @@ -72,13 +71,6 @@ import { toObject } from './methods/toObject';

export { Collection, CollectionPrototype, IndexedCollectionPrototype };

// Note: all of these methods are deprecated.
Collection.isIterable = isCollection;
Collection.isKeyed = isKeyed;
Collection.isIndexed = isIndexed;
Collection.isAssociative = isAssociative;
Collection.isOrdered = isOrdered;

Collection.Iterator = Iterator;

mixin(Collection, {
Expand Down
11 changes: 0 additions & 11 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ export class Map extends KeyedCollection {
});
}

static of(...keyValues) {
return emptyMap().withMutations(map => {
for (let i = 0; i < keyValues.length; i += 2) {
if (i + 1 >= keyValues.length) {
throw new Error('Missing value for key: ' + keyValues[i]);
}
map.set(keyValues[i], keyValues[i + 1]);
}
});
}

toString() {
return this.__toString('Map {', '}');
}
Expand Down
46 changes: 0 additions & 46 deletions type-definitions/immutable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,24 +792,6 @@ declare namespace Immutable {
* ```
*/
function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;

/**
* Creates a new Map from alternating keys and values
*
* <!-- runkit:activate -->
* ```js
* const { Map } = require('immutable')
* Map.of(
* 'key', 'value',
* 'numerical value', 3,
* 0, 'numerical key'
* )
* // Map { 0: "numerical key", "key": "value", "numerical value": 3 }
* ```
*
* @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' })
*/
function of(...keyValues: Array<unknown>): Map<unknown, unknown>;
}

/**
Expand Down Expand Up @@ -3590,34 +3572,6 @@ declare namespace Immutable {
* `Collection.Indexed`, or `Collection.Set`.
*/
namespace Collection {
/**
* @deprecated use `const { isKeyed } = require('immutable')`
*/
function isKeyed(
maybeKeyed: unknown
): maybeKeyed is Collection.Keyed<unknown, unknown>;

/**
* @deprecated use `const { isIndexed } = require('immutable')`
*/
function isIndexed(
maybeIndexed: unknown
): maybeIndexed is Collection.Indexed<unknown>;

/**
* @deprecated use `const { isAssociative } = require('immutable')`
*/
function isAssociative(
maybeAssociative: unknown
): maybeAssociative is
| Collection.Keyed<unknown, unknown>
| Collection.Indexed<unknown>;

/**
* @deprecated use `const { isOrdered } = require('immutable')`
*/
function isOrdered(maybeOrdered: unknown): boolean;

/**
* Keyed Collections have discrete keys tied to each value.
*
Expand Down