feat(notification): Add overload support for notify function to enhance flexibility#289
Open
sanduluca wants to merge 3 commits into
Open
feat(notification): Add overload support for notify function to enhance flexibility#289sanduluca wants to merge 3 commits into
sanduluca wants to merge 3 commits into
Conversation
Added overloads to the `notify` function to support flexible usage patterns, allowing calls with title, description, setup, or combinations of these. Updated the implementation to handle different argument structures dynamically.
Contributor
|
Hi @sanduluca thanks for such improvement, I like TS's ability to implement a function overload mechanism. Give me a couple of days, I'll take a look and see if we can release it. |
Contributor
Author
|
up |
PdoubleU
reviewed
Mar 21, 2025
Comment on lines
+19
to
+22
| notificationType: any, | ||
| titleOrSetup: any, | ||
| descriptionOrSetup?: any, | ||
| setup?: any |
Contributor
There was a problem hiding this comment.
Is there a better option than 'any' here? Maybe doesn't type as 'any' but use only the inferred types from the Notify
Contributor
|
In general good PR, I'd like to test it first to check if it has fully backward compatibility with the current interface. Then deploy :) |
The main issue here is that Notify is a function type with multiple overloads, meaning it can accept different sets of parameters. TypeScript resolves function overloads at the call site, not within the function implementation. This makes it difficult to infer a generic tuple type for the parameters in a way that works across all overloads. Workarounds - Explicit Typing - Explicit Overload Handling - Conditional Type Checking
Contributor
Author
|
kind reminder |
PdoubleU
approved these changes
Jun 12, 2025
PdoubleU
approved these changes
Jun 12, 2025
Contributor
Author
|
Hey @PdoubleU, thank for approving this. Can this be merged as well ? |
Contributor
Author
|
Hi. Any plans merging this ? |
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.
This PR introduces overload support for the notify function, enabling it to handle multiple usage patterns in a type-safe manner. The changes improve developer ergonomics by allowing the function to be called in various ways:
Supported Call Patterns
Key Changes
Motivation
The notify function previously required a rigid setup object for all calls, which reduced flexibility. These enhancements allow developers to quickly show notifications with minimal boilerplate while retaining the ability to configure advanced notification options.
Examples
Let me know if any additional information or refinements are needed!