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

BREAKING: Remove Iterable<T> as tuple from Map constructor types #1626

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 27, 2018
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
2 changes: 0 additions & 2 deletions 2 type-definitions/Immutable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ declare module Immutable {
* not altered.
*/
export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
export function Map<T>(collection: Iterable<Iterable<T>>): Map<T, T>;
export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
export function Map<K, V>(): Map<K, V>;
export function Map(): Map<any, any>;
Expand Down Expand Up @@ -1419,7 +1418,6 @@ declare module Immutable {
* the `new` keyword during construction.
*/
export function OrderedMap<K, V>(collection: Iterable<[K, V]>): OrderedMap<K, V>;
export function OrderedMap<T>(collection: Iterable<Iterable<T>>): OrderedMap<T, T>;
export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
export function OrderedMap<K, V>(): OrderedMap<K, V>;
export function OrderedMap(): OrderedMap<any, any>;
Expand Down
17 changes: 7 additions & 10 deletions 17 type-definitions/ts-tests/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ import { Map, List } from '../../';
// $ExpectType Map<{}, {}>
Map();

// $ExpectType Map<number, number>
Map([[1, 1]]);
// $ExpectType Map<number, string>
Map([[1, 'a']]);

// $ExpectType Map<number, string>
Map(List<[number, string]>([[1, 'a']]));

// $ExpectType Map<string, number>
Map({ a: 1 });

// $ExpectType Map<string, string>
Map(List.of(List(['a', 'b'])));

// $ExpectType Map<number, number>
Map(List.of(List([1, 2])));

// $ExpectType Map<string | number, string | number>
Map(List.of(List(['a', 1])));
// $ExpectError - TypeScript does not support Lists as tuples
Map(List([List(['a', 'b'])]));

// $ExpectError
const invalidNumberMap: Map<number, number> = Map();
Expand Down
17 changes: 7 additions & 10 deletions 17 type-definitions/ts-tests/ordered-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ import { OrderedMap, List } from '../../';
// $ExpectType OrderedMap<{}, {}>
OrderedMap();

// $ExpectType OrderedMap<number, number>
OrderedMap([[1, 1]]);
// $ExpectType OrderedMap<number, string>
OrderedMap([[1, 'a']]);

// $ExpectType OrderedMap<number, string>
OrderedMap(List<[number, string]>([[1, 'a']]));

// $ExpectType OrderedMap<string, number>
OrderedMap({ a: 1 });

// $ExpectType OrderedMap<string, string>
OrderedMap(List.of(List(['a', 'b'])));

// $ExpectType OrderedMap<number, number>
OrderedMap(List.of(List([1, 2])));

// $ExpectType OrderedMap<string | number, string | number>
OrderedMap(List.of(List(['a', 1])));
// $ExpectError - TypeScript does not support Lists as tuples
OrderedMap(List([List(['a', 'b'])]));

// $ExpectError
const invalidNumberOrderedMap: OrderedMap<number, number> = OrderedMap();
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.