Hello, trying to type narrow using an instanceof check in a helper that returns a boolean. I would expect that if I use an if statement with the helper, the next line would type narrow. However it doesn't.
However, while type narrowing works without a helper function. With a helper function it doesn't seem to work. See sample below
class testing {};
// this code doesn't work
const check = (arg1: any) => {
return arg1 instanceof testing
}
const doesTypeWork = (arg1: any) => {
if (check(arg1)) {
const me = arg1; // still shows as any ????
}
}
// this code does work
const checkThatWorks = (arg1: any) => {
if (arg1 instanceof testing) {
const something = arg1 // the type narrowing is successful! TypeScript sees this as
}
}