-
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
asserts
keyword with intersection type is not working
#56256
Comments
The type It's not clear what you actually want and how it should work. Assertion functions don't return anything. You're just declaring that whatever If I had to guess I'd say you want #40562, and just mistakingly throw unrelated terms together (the intersection type). Regardless, the error is correct. There is no bug here. |
Got it, what I want is to making a function returning |
That would be a feature request, not a bug report, and it already exists: #40562 Currently such functions are not possible. |
Thanks for fast response. I should consider another way. |
π Search Terms
π Version & Regression Information
Occurs since v3.7 update, the first update supporting the
asserts
statement.β― Playground Link
https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVwIYDOBwsAyjFJigOYAUVYSMAXHKgNYoQDuKAlK0LFYBOAyZjRBClWpwAZHGmUacAN4AoONrEI4tGAE8wwCHvHwAhAF5rcAOTLZ9vlp3uYACyg84KYNxwAKJQPlC09gCSKIzwmKJc8HhKMjQuANxu2lDAMEhQuBaZAL5AA
π» Code
π Actual behavior
It is possible to declare an
asserts
guard function with intersection return type. There's no error until that.However, the intersection return type does not work, and just working as a
void
return type.π Expected behavior
Hope the intersection return type to work.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: