Type Guard for interface
npm install is-interface
import is from "@sindresorhus/is";
import { isInterface } from "is-interface";
declare const someObject: unknown;
if (
isInterface(someObject, {
foo: is.string,
bar: is.number,
baz: is.boolean,
})
) {
someObject;
// const someObject: {
// foo: string;
// bar: number;
// baz: boolean;
// }
}
- is - Type guards for any situation