Either understand const arrow assertions or give better errors on them #36067
Labels
Domain: Error Messages
The issue relates to error messaging
Experience Enhancement
Noncontroversial enhancements
In Discussion
Not yet reached consensus
Rescheduled
This issue was previously scheduled to an earlier milestone
Suggestion
An idea for TypeScript
As mentioned by @threehams in #35838 (comment), people are pretty confused about the rules for assertion functions, and I don't blame them. For example
In our nightly releases, we give an elaboration on the declaration of
assert
likeFor all intents and purposes, it looks like
assert
does have an annotation! The problem is thatassert
itself needs a: (x: unknown) => asserts x
, because it's not automatically inferred from the arrow function.We have two options:
Remove this restriction when the declaration of an assertion function is trivially detectable.
Make assertion function errors more clear for arrow functions:
The text was updated successfully, but these errors were encountered: