Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a type.is method to attest that will statically assert bidirectional equality #1016

Open
ssalbdivad opened this issue Jun 17, 2024 · 0 comments

Comments

@ssalbdivad
Copy link
Member

Inspired by a suggestion from @colinhacks implemented in typejest.

Getting the types in place would be straightforward using the exactEquals util from @arktype/util.

The more important part will be adding logic to the type-checking phase to store data from an extra generic arg for is like:

// ok
attest("foo").type.is<string>();

// this needs to throw at runtime and have a type error,
// likely by requiring an extra parameter on is with an ErrorMessage
attest("foo").type.is<any>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant