x/evt@v1.10.2/tools/typeSafety/matchVoid.ts

šŸ’§EventEmitter's typesafe replacement
GitHub Stars
382
Go to Latest
/** * * Unlike undefined or null, testing o !== void * will not restrict the type. * * Example: * * declare o: { p: string; } | void; * * matchVoid(o)?null:o.p <== Type inference ok * * Match void * @param o type of o should be a union of type containing void * @returns true if o is undefined */export function matchVoid(o: any): o is void | undefined { return o === undefined;}