Skip to content

Comments

fix(types): Remove useless SortableSet iterator#18751

Closed
slorber wants to merge 1 commit intowebpack:mainfrom
slorber:patch-1
Closed

fix(types): Remove useless SortableSet iterator#18751
slorber wants to merge 1 commit intowebpack:mainfrom
slorber:patch-1

Conversation

@slorber
Copy link

@slorber slorber commented Sep 10, 2024

Fix TypeScript 5.6 typing problem due to Iterator changes:

CleanShot 2024-09-10 at 12 51 57@2x

Useful links:

What kind of change does this PR introduce?

Remove custom iterator type for SortableSet:

declare abstract class SortableSet<T> extends Set<T> {
	/**
	 * Iterates over values in the set.
	 */
	[Symbol.iterator](): IterableIterator<T>;
}

The implementation does not create a custom iterator so IMHO this declaration could be removed to use the built-in parent Set iterator.

interface Set<T> {
    /** Iterates over values in the set. */
    [Symbol.iterator](): SetIterator<T>;
}

Note: the iterator type you previously used was the former built-in type. But that built-in type changed in TS 5.6. Refs:

Did you add tests for your changes?

Not sure how to test this, apart from upgrading the whole repo to TS 5.6

Does this PR introduce a breaking change?

It shouldn't?

What needs to be documented once your changes are merged?

Nothing?

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatibility with typescript 5.6

2 participants