Skip to content

Latest commit

History

History
33 lines (24 loc) 路 633 Bytes

README.md

File metadata and controls

33 lines (24 loc) 路 633 Bytes

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);

鈿狅笍 Limitations:

  • It has to be a curried function
  • Supported types depend on Exact implementation