4 ms·
You can do the converse: create a type guard asserting a structure, and then extract a type. type Spec<T> = T extends (x: unknown) => x is infer U ? U : neve
by jakelazaroff 6y ago
You can do the converse: create a type guard asserting a structure, and then extract a type.
type Spec<T> = T extends (x: unknown) => x is infer U ? U : never;
type Foo = Spec<typeof someTypeGuard>;