EVT
Search…
Evt.loosenType(evt)
This is the identity function with special type annotations.
Swipe the type argument with a superset without giving up type safety.
If A is assignable to BEvt<A> is assignable to Evt<B>
e.g:Evt<1|2|3> is assignable to Evt<number> however typescript wont let you do this assignation. This is where Evt.loosenType come in handy.
1
import { Evt } from "evt";
2
3
declare const evFooBar: Evt<"FOO" | "BAR">;
4
declare function myFunc(evtText: Evt<string>): void;
5
6
myFunc(evtFooBar); //Gives a type error;
7
myFunc(Evt.loosenType(evtFooBar)); //OK
Copied!
Last modified 1yr ago
Copy link