- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 3.6.2
Search Terms:
Code
functiongetValue(): string{return'1';}functionisNumber(value: any): value is number{returntypeofvalue==='number'&&!Number.isNaN(value)&&Number.isFinite(value);}functionmain(){letvalue=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:
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug