Replies: 2 comments 3 replies
-
As far as I know this kind of thing is only possible with user-defined type predicates, which are a chore. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Related, I'm really looking forward to when I can use this in pattern matching: interface point
x: number
y: string
switch v
<? point
...
---
interface point {
x: number
y: string
}
if (typeof v === "object" && v != null && typeof(v.x) === "number" && typeof(v.y) === "string") {
...
} Before we understand type references though (looking up switch v
{x:: number, y:: string} (originally posted #296 (comment)) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be great if we could use is or as something similar to disambiguate between types in a union type, especially if they are not primitives (so when typeof doesn't help). Eg:
Beta Was this translation helpful? Give feedback.
All reactions