Skip to content

Bluebird.hx type error chaining * -> Void functions with .then() #75

Description

@laurence-myers

I'm having trouble chaining functions/promises using the Bluebird extern. I believe Haxe's type inference engine is failing to deduce the return type of a fulfilledHandler that comes after a fulfilledHandler with a return type of Void.

Here's a small test case that exhibits the problem:

import buddy.BuddySuite;
import js.npm.Bluebird;
using buddy.Should;

class TestBluebird extends BuddySuite {
    public function new() {

        describe("Testing Bluebird", function () {
            it("Allows chaining after a '* -> Void' function", function (done) {
                var p = new Bluebird(function (resolve, reject) {
                    resolve("first value");
                }).then(function (firstValue) {
                    firstValue.should.be("first value");
                }).then(function () {
                    done();
                });
            });
        });
    }
}

I think I can work around the issue by returning "null" in one function and accepting a dummy arg in the next, but this is awkward for chaining existing functions together, and problematic for making use of externs or libs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions