Since abort immediately returns, it should be declared with return type never. That lets TypeScript smart cast values that have been guarded by an abort, because it knows that function never returns. For example:
const match = regexp.exec(text);
if (!match) kolmafia.abort('Expected to find match.');
const ix = match[1]; // fails --> TS2531: Object is possibly 'null'.
If kolmafia.abort returned never, this would compile as expected, while still being fully type-safe.
(This was the first example I had at hand, let me know if you need a better one.)
Since abort immediately returns, it should be declared with return type never. That lets TypeScript smart cast values that have been guarded by an abort, because it knows that function never returns. For example:
If
kolmafia.abort
returnednever
, this would compile as expected, while still being fully type-safe.(This was the first example I had at hand, let me know if you need a better one.)