-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
Issue with js.Promise.then() type inference #6790
Comments
This is a more general issue with unifying functions against abstracts (which EitherType is): abstract Callback(Dynamic) from Int->Void {}
class Main {
static function main() {
var f:Int->Void = function(t) $type(t); // Int
var f2:Callback = function(t) $type(t); // Unknown<0>
}
} Probably comes from the fact that with abstracts there can be multiple For the |
Thanks for looking into this! (I decided to separate the 'empty promise' request into its own issue, #6793) |
Here's some typescript folks struggling with the same issue: |
There is a lot of type magic (Either's, parameters) in
js/Promise.hx
to mirror the behavior of JavaScript's Promise. Unfortunately, somewhere in all this magic, we lose type inference to the argument of the then callback.Promise.then()
type inference not working: https://try.haxe.org/#aa552NotAPromise.then()
type inference IS working: https://try.haxe.org/#b052aMy brain cannot wrap through all the type magic to know whether this is expected or not, or which exact feature breaks the inference, but from an end user perspective, I'd like
Promise.then()
to work as well asNotAPromise.then()
The text was updated successfully, but these errors were encountered: