I want to make a general purpose typegaurd. The docs(https://basarat.gitbook.io/typescript/type-system/typeguard) usually split this into multiple steps, one for each type/interface
foo: number;
common: string;
}
function isFoo(arg: any): arg is Foo {
return arg.foo !== undefined;
}```
and then another function to act on it
```function doStuff(arg: Foo | Bar) {
if (isFoo(arg)) {
console.log(arg.foo); // OK
console.log(arg.bar); // Error!
}
else {
console.log(arg.foo); // Error!
console.log(arg.bar); // OK
}
}```
Is it impossible to do something like this instead: ```function isInterfaceMatch(arg: any, match: Interface): arg is match{
return true
}
isInterfaceMatch(x, Foo)```