Closed
Description
@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.
Metadata
Metadata
Assignees
Labels
No labels