Skip to content

Commit

Permalink
Fix Set.fromKeys types with Map constructor in TS 5.0 (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau committed Jan 26, 2024
1 parent 4370259 commit 2342972
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"transducers-js": "0.4.174",
"tslint": "6.1.3",
"tslint-config-prettier": "1.18.0",
"typescript": "^4.9",
"typescript": "5.0",
"uglify-js": "3.11.1",
"uglify-save-license": "0.4.1"
}
Expand Down
4 changes: 4 additions & 0 deletions type-definitions/immutable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,8 @@ declare namespace Immutable {
* `Set.fromKeys()` creates a new immutable Set containing the keys from
* this Collection or JavaScript Object.
*/
function fromKeys<T>(iter: Collection.Keyed<T, unknown>): Set<T>;
// tslint:disable-next-line unified-signatures
function fromKeys<T>(iter: Collection<T, unknown>): Set<T>;
function fromKeys(obj: { [key: string]: unknown }): Set<string>;

Expand Down Expand Up @@ -1936,6 +1938,8 @@ declare namespace Immutable {
* `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing
* the keys from this Collection or JavaScript Object.
*/
function fromKeys<T>(iter: Collection.Keyed<T, unknown>): OrderedSet<T>;
// tslint:disable-next-line unified-signatures
function fromKeys<T>(iter: Collection<T, unknown>): OrderedSet<T>;
function fromKeys(obj: { [key: string]: unknown }): OrderedSet<string>;
}
Expand Down
2 changes: 1 addition & 1 deletion type-definitions/ts-tests/ordered-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { OrderedSet, Map } from 'immutable';
{
// .fromKeys

// $ExpectType OrderedSet<string>
// $ExpectType OrderedSet<number>
OrderedSet.fromKeys(Map<number, string>());

// $ExpectType OrderedSet<number>
Expand Down
4 changes: 2 additions & 2 deletions type-definitions/ts-tests/set.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Set, Map } from 'immutable';
import { Set, Map, Collection } from 'immutable';

{
// #constructor
Expand Down Expand Up @@ -39,7 +39,7 @@ import { Set, Map } from 'immutable';
{
// .fromKeys

// $ExpectType Set<string>
// $ExpectType Set<number>
Set.fromKeys(Map<number, string>());

// $ExpectType Set<number>
Expand Down

0 comments on commit 2342972

Please sign in to comment.