Skip to content

Extend fromPredicate type to support type guards#755

Merged
gigobyte merged 2 commits intogigobyte:masterfrom
mendrik:Maybe.fromGuard
Nov 13, 2025
Merged

Extend fromPredicate type to support type guards#755
gigobyte merged 2 commits intogigobyte:masterfrom
mendrik:Maybe.fromGuard

Conversation

@mendrik
Copy link
Contributor

@mendrik mendrik commented Nov 12, 2025

No description provided.

@gigobyte
Copy link
Owner

I believe instead of a new method, you can add it as a function overload on fromPredicate, like how the types for Array.filter are implemented:

filter<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[];
filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[];

@mendrik
Copy link
Contributor Author

mendrik commented Nov 13, 2025

I believe instead of a new method, you can add it as a function overload on fromPredicate, like how the types for Array.filter are implemented:

true dat!

@mendrik mendrik changed the title Add fromGuard method and tests for conditional value extraction Extend fromPredicate type to support type guards Nov 13, 2025
@mendrik mendrik requested a review from gigobyte November 13, 2025 10:40
@gigobyte gigobyte merged commit c3f84e2 into gigobyte:master Nov 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants