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

feat request: typescript #60

Open
trusktr opened this issue May 21, 2020 · 2 comments
Open

feat request: typescript #60

trusktr opened this issue May 21, 2020 · 2 comments

Comments

@trusktr
Copy link

trusktr commented May 21, 2020

These would be sweet as type guard functions in TypeScript.

As an example,

const blah: unknown = undefined
let s: string = ''

if (upcast.is(blah, 'string')) {
 s = blah // ok
}
else {
  s = blah // type error
}

working sample implementation on TypeScript playground. Hover on blah within both branches of the conditional.

@OmgImAlexis
Copy link
Owner

I’ll get to this soon. I’ve already got a typescript fork I’m using at work.

@nicobees
Copy link

nicobees commented Jun 7, 2023

@OmgImAlexis hello, I know is old thread...but any chance you might share the types for upcast.js file? 🙏

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

No branches or pull requests

3 participants