isExact<Expected>()(actual)
matches runtime function, which validates that type of actual
equals to Expected
interface Dog {
name: string;
bark: () => void;
}
interface Cat {
name: string;
meow: () => void;
}
const isCat = isExact<Cat>();
It validates equality of types, otherwise TypeScript shows an error
declare const dog: Dog;
declare const cat: Cat;
// error: Argument of type 'Dog' is not assignable to parameter of type 'never'.
isCat(dog);
// ^^^
isCat(cat);
- It has to be a curried function
- Supported types depend on
Exact
implementation