Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
What changes did you make?
mitt<{ foo: string }>().off('*')removes every wildcard listener at runtime, but TypeScript rejects it because the wildcard overload requires a handler. Make that handler optional, matching the documented behavior and the maintainer's example in #150.Add strict type checks for an omitted handler and explicit
undefined, plus a runtime check that named listeners remain registered. Existing checks that reject the wrong wildcard callback type remain in place.Validation
The new type calls fail on the original declaration with TS2345/TS2769. After the change,
npm run bundleand the fullnpm testsuite pass on Node 18 (20 runtime tests, strict type checks and lint). The repository's existingesmloader is incompatible with the local Node 22 runtime, so the suite was run on Node 18 with compatible Node type declarations. No package changes are included.Is there anything you'd like reviewers to focus on?
The wildcard overload now permits the same handler omission as the named-event overload.
Does this PR introduce a breaking change?
No; it expands the type declaration to accept an existing runtime operation.