-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add support for "this is X" style user-defined type guards #5764
Comments
Looks like a good suggestion to me. |
It looks like this wasn't implemented as described. I can't seem to set a type guard on a getter like in the example above, only on regular functions. On a getter, I'm told "A type predicate is only allowed in return type position for functions and methods." |
that is correct. you can find more documentation in https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#this-based-type-guards |
I read that already, doesn't talk about this at all... |
User define guards are not supported in property declaration or acccessor (getter or setter). that as specified in the original proposal, but was cut from the implementation. |
I'd like to use user-defined type guards in the following manner:
This use-case was suggested by @RyanCavanaugh when he opened #1007 but seems to be unsupported as of TypeScript 1.6.
The text was updated successfully, but these errors were encountered: