Closed
Description
TypeScript Version: 3.6.2
Search Terms:
Code
function getValue(): string {
return '1';
}
function isNumber(value: any): value is number {
return typeof value === 'number' && !Number.isNaN(value) && Number.isFinite(value);
}
function main() {
let value = getValue();
if (isNumber(value) && value.length === 4) {
value++;
}
}
main();
Expected behavior:
The compare in the line if (isNumber(value) && value.length === 4)
in the above example would always fail but did compile without type error in TypeScript 3.5.3.
Actual behavior:
In TypeScript 3.6.2 the line generates error TS2339: Property 'length' does not exist on type 'never'
and I do not understand why this would be a type error?
Playground Link:
Related Issues: