ForbesLindesay / funtypes

Runtime validation for static types
MIT License
29 stars 4 forks source link

Add top level assert helper #23

Open ForbesLindesay opened 4 years ago

ForbesLindesay commented 4 years ago

Something like:

function assertType<TRuntypeBase extends RuntypeBase>(
  rt: TRuntypeBase,
  v: unknown,
): asserts v is Static<TRuntypeBase> {
  (rt as any).assert(v);
}

Requested in https://github.com/pelotom/runtypes/issues/110

Needed because of microsoft/TypeScript#36931