upcast icon indicating copy to clipboard operation
upcast copied to clipboard

feat request: typescript

Open trusktr opened this issue 5 years ago • 2 comments

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.

trusktr avatar May 21 '20 02:05 trusktr

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

OmgImAlexis avatar May 21 '20 05:05 OmgImAlexis

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

nicobees avatar Jun 07 '23 06:06 nicobees