Skip to content

Instantly share code, notes, and snippets.

@lumie1337
Created November 30, 2018 10:09
Show Gist options
  • Save lumie1337/67f2473c94111ff683f3028bbe7006b2 to your computer and use it in GitHub Desktop.
Save lumie1337/67f2473c94111ff683f3028bbe7006b2 to your computer and use it in GitHub Desktop.
let my_number_var: number;
function ffi(var_from_js: unknown) {
// forces you to do this
if(typeof var_from_js === "number")
my_number_var = var_from_js
else
throw new Error("invalid use of api")
}
@lumie1337
Copy link
Author

(T & unknown) is always a subtype of T, because (A & B) extends A holds
(T | unknown) can always be understood to be unknown, thereby rendering the T meaningless; because A extends (A | B) holds

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