Closed AlCalzone closed 2 hours ago
This is working as intended / a design limitation. See #32695.
A function call is analyzed as an assertion call or never-returning call when
- the call occurs as a top-level expression statement, and
- the call specifies a single identifier or a dotted sequence of identifiers for the function name, and
- each identifier in the function name references an entity with an explicit type, and
- the function name resolves to a function type with an
asserts
return type or an explicitnever
return type annotation.
validate
does not have an explicit type.
Edit: I was too fast. Thanks for the update, it does work with an explicit type annotation on validate
.
Is that because
validate
has no type annotation?
Correct, it has no explicit type. I just edited my comment to add that information. This limitation was added for performance reasons.
🔎 Search Terms
function member never ts2534
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.7.0-dev.20240925#code/C4TwDgpgBAaghgGwJYBM7CQewHYDECu2AxhjlALxQAUAdHXAM4MQBOp2DAXFIQNbaYA7tgDaAXQCUFAHxQAbplQBuAFAqk2YKwBmcItHjI0WqBAAeW7CgaxEqdFjyESjqAG8VASF1IEVCdzYEHKsqgC+atrO7PJ2xhAAkpqs2Ii09Eys7Fw82PxCopLcCqjuXkja1ACEjMxsjgw0wawgVABCmJgIEHDYElIenp7AABYsQlBBglAAoizjLFQARHJxDmQ+3ShLEqqeEREqRDgMwLFG6NCUqxdaSVosqQg0AEYaKFSEKBDaGhAoUkYtluEFUN3sWhomwo1Ck5Fk4PiVF0CGYgJsfAEwigQKCIRYqki0Vcm38gWaLDKUHOEIgULgvn8qmpAHoWdSORyAHoAfhUhyixBiQVO-1wDL8AUmFLKnjZk0wpnmmEpI1YEC8pN2XnlvP5ahFWhQ4sZuyg8tGSBso3Gghs7wg-xUCEwAHNlihSgIzjahDtVEA
💻 Code
🙁 Actual behavior
TS complains about the
never
return type offunction fail()
:🙂 Expected behavior
No errors
Additional information about the issue
No response