[keyserver/lib] Improve tcomb types
Summary:
These changes should improve:
- Better union validators, by making the generics covariant (+). Previously flow would fail at t.union([t.String, t.Bool]) but now types it as TUnion<string | boolean>
- Making TInterface, TStructProps and tShape generic, and now tShape<{a: boolean, b: string}>({a: t.Bool, b: t.String}) will be typechecked (both the type argument and validator argument have to match)
- Instead of TType<T> being at the top of an inheritence hierarchy, it's now a union of the possible validator types. Additionaly meta.kind has now specific values for each validator type (taken from tComb docs). This allows us to check the type of the validator with meta.kind and type-safely get e.g. meta.type when meta.kind === 'maybe'
The last change also required a slight change of meaning of the generic T for some validators. For example previously: TList<T> = TType<Array<T>>, and now TList<Array<T>> = TType<Array<T>>. This is also clearer (at least to me): now for every validator variant the generic type represents the whole type that is validated. This theoretically allows for nonsesical types like TList<NonArrayType> but this can't happen if we are using the t.list, t.dict etc. functions.
Test Plan: Run yarn flow and check for errors
Reviewers: kamil, inka, tomek, ashoat
Reviewed By: ashoat
Subscribers: ashoat, atul
Differential Revision: https://phab.comm.dev/D7467