Skip to content

Conversation

@EskiMojo14
Copy link
Contributor

fixes #1089

@vercel
Copy link

vercel bot commented May 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valibot ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 8:33pm

@EskiMojo14
Copy link
Contributor Author

EskiMojo14 commented May 25, 2025

image

leaving this as draft now as i can't work out how to allow type guards that accept wider types than the current pipe type

edit: switching back to the previous overloads half fixes the issue - it's now complaining when the output type is wider than the input type
image

@fabian-hiller fabian-hiller self-requested a review May 26, 2025 01:12
@fabian-hiller fabian-hiller self-assigned this May 26, 2025
@fabian-hiller fabian-hiller added the enhancement New feature or request label May 26, 2025
@fabian-hiller fabian-hiller added this to the v1.2 milestone May 26, 2025
@fabian-hiller fabian-hiller requested a review from Copilot May 26, 2025 01:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new guard action and corresponding type definitions to enable narrowing using type predicates in the transformation framework. Key changes include:

  • Adding new API links and documentation for the guard action in markdown files.
  • Defining and exporting new types and properties for GuardIssue and GuardAction across the API and type folders.
  • Implementing the guard function in the library with associated tests covering functionality and type inference.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/src/routes/api/menu.md Added menu links for guard and its related issues/actions.
website/src/routes/api/(types)/GuardIssue/* Introduced new property definitions and documentation for GuardIssue.
website/src/routes/api/(types)/GuardAction/* Added type properties and documentation for GuardAction.
website/src/routes/api/(actions)/guard/* Created properties and docs for the guard action along with usage examples.
library/src/actions/guard/* Implemented the guard function, interfaces, and tests ensuring correct behavior and type inference.

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 26, 2025

Open in StackBlitz

npm i https://pkg.pr.new/valibot@1204

commit: d60576d

@fabian-hiller
Copy link
Owner

Thank you for working on this! I plan it for our v1.2 release. Feel free to mark it as ready once you are done. After that I will take over, review everything and merge it.

@EskiMojo14 EskiMojo14 marked this pull request as ready for review May 26, 2025 20:31
@EskiMojo14
Copy link
Contributor Author

EskiMojo14 commented May 26, 2025

found a fix (involving lots of any, unfortunately, though only in positions where a more specific type will be kept later) - should be ready for review :)

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check action to infer return type from a passed typeguard

2 participants