What is the equivalent of never TypeScript type in Flow?
I am working on a project which uses flow for type checking. There I have to define a throwing function. In Typescript we can use never type for function which do not return. I want to do the same with flow but didn’t found anything in the documentation.
I have a condition for invalid types.
if(type == 'a' || type == 'b'){
throw new Error();
}
return type;
the function which contains this code has a type which does not include "a" and "b". The above code works. But when i move the if condition in a function it does not work.
function throwIfInvalidType(type) {
if(type == 'a' || type == 'b'){
throw new Error();
}
}
And then use the function as below it does not work.
throwIfInvalidType(type)
return type;