Rust's `-> !` equivalent in TS
I tried
(): never
, but it did not work.
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBADgQzAS2DAvDAFAWwKYQQIDmeAXDNAE7JjECUFYeAbnlRgHwwDeAUDEEwoACyogA7jGZSAolXFVcBIqXp8Avnz6hIsCCHwBZBHAzS8Uk3AA81WsQA0lKDTqcs6neGiVDeUQdzA2NTADpSKCwAIhEQUmivZAAzbABCEICRB3peASFEFGAYgAUkVDTEzW1MwLo+AHoGmAA9AH4gATS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
3 Replies
GitHub
Call to function returning never can not be used to narrow type · I...
TypeScript Version: 2.3.2 A function that never returns (return type never) can not be used in a type guard to narrow the type after the branch. Code class Thing { }; function diverges(): never { t...
GitHub
Generalize
never
type handling for control flow analysis based ty...I guess there would be some duplicates, but I cannot find it. TypeScript Version: 2.1.14 Code function throwError(): never { throw new Error(); } let foo: string | undefined; if (!foo) { throwError...
I see; thanks!