Open
Description
openedon Dec 12, 2019
Hey there!
I’m updating Programming TypeScript to include assertions in control flow analysis, and was looking for guidance about naming.
Type assertions (x as T
) and assertions in control flow analysis (asserts x is T
) are similarly named. What’s a good way to call these these features, in a way that doesn’t confuse people and aligns with the way the TS team is communicating it?
A couple of ideas:
- Rename
x as T
to “type coercion” or “type casting" (even though it’s not a runtime behavior), and callasserts x is T
a “type assertion” - Keep
x as T
as-is (“type assertion”), and callasserts x is T
a “user-defined type assertion”, similar to a “user-defined type guard”
Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment