@ahejlsberg you probably already know about this one but I thought I'd confirm:
interface Error {
e
}
declare function isError(value: any): value is Error;
class CustomError extends Error { }
function narrowTest(value: number | CustomError) {
if(isError(value)) {
let result: CustomError = value;
}
else {
let result: number = value; // error!
}
}
Expected: narrowing to number in the else branch.
Actual: No narrowing: value: CustomError | number in the else branch, causing an error.
I found this in lodash on DefinitelyTyped.
@ahejlsberg you probably already know about this one but I thought I'd confirm:
Expected: narrowing to
numberin the else branch.Actual: No narrowing:
value: CustomError | numberin the else branch, causing an error.I found this in
lodashon DefinitelyTyped.