Say I have a function that checks if a parameter is string defined like this :
function isString(value: any): boolean {
return typeof value === 'string' || value instanceof String;
}
Now when I use this function with typescript 2.0 control flow analysis I would expect the following to work :
function foo(param: string|Foo) {
if(isString(param)) {
// param is not narrowed to string here
} else {
// param is not narrowed to Foo here
}
}
Is there a different way I could define isString that would make the example if statement narrow the type of param correctly ?