[Flow Analysis] throw
statements in nested function calls
#32602
Labels
Duplicate
An existing issue was already created
throw
statements in nested function calls
#32602
Search Terms
flow analysis throw error exception undefined non-null assertion optional nested function call
Suggestion
Teach flow analysis to understand
throw
statements in nested function calls.Use Cases
Many frameworks, even Node's standard library, come with a range of assertion helpers. In its most basic form, they take a
condition
, and an errormessage
that will be thrown, when thecondition
evaluates to a false / falsy value.TypeScript currently does not understand
throw
statements in nested function calls, which makes usingassert
helpers annoying, since you have either have to repeat the same conditional throw statement right after the assertion, use a non-null assertion, or a type cast, to tell TypeScript, that this value is present / fulfills some further criteria.Examples
TypeScript REPL
Checklist
My suggestion meets these guidelines:
Possible Duplicates / Related
The text was updated successfully, but these errors were encountered: