-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Union types with enum and class not working property #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You need to use
where as |
Another way to write this, keeping enum (with a few code simplications too):
|
Thanks for the info! I figured I was probably doing something that wasn't meant to be done. I really appreciate the last code snippet!!! That is definitely the route I will go. Thanks again! |
Actually there is a bug that's preventing this from working correctly: see #1718. The solution proposed above is problematic because there is no narrowing of p = new FilterExpression(p.foo); // would still work because p is `any` Once the bug fix is released one should be able to write AddFilter(p: LogicalOperator | FilterExpression): void {
if (typeof p === "number")
var x = new FilterExpression(p); // Safer
this.Filters.push(x);
} |
From what I understand, the following should work but it is generating errors:
If I change it to this then I don't get any errors
The text was updated successfully, but these errors were encountered: