Attempting to assign the result of a function typed as :void or :never should cause an Error #57773
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
🔍 Search Terms
"void function result assignment", "never function result assignment", "void functions assignment error", "disallow void and never assigning"
⭐ Suggestion
Functions that don't return any value are typed as
:void
or:never
. However, currently, it's possible to assign the execution result of these functions without any warning or error. In the case of:void
type, it will returnundefined
(the default return value in JavaScript), and in the case of:never
, its result isn't reachable at all. So, how can we assign it? Obviously, it makes no sense.📃 Motivating Example
💻 Use Cases
For consistency with other strongly typed programming languages, where we cannot assign the result of executing
:void
and:never
functions.The text was updated successfully, but these errors were encountered: