Skip to content

Request object not unifying with IncomingMessage #177

@fullofcaffeine

Description

@fullofcaffeine

Why doesn't js.npm.express.Request from haxe-js-kit unify with js.node.http.IncomingMessage? If you check the definition for the Express Request object, here: https://github.com/expressjs/express/blob/master/lib/request.js, you'll see that it extends http.IncomingMessage. The express TS type definitions seem to be ok, the req object passed by the use method callback correctly unifies with IncomingMessage, i.e:

Typescript code:

function bar(foo: http.IncomingMessage) {}
app.use('/tink_api', (req: express.Request, res: express.Response, next) => {
  bar(req); // works fine, no TS errors
});

But that doesn't work with Haxe when using js-kit:

Haxe code:

function bar(foo: js.node.http.IncomingMessage) {}
app.use('/tink_api', (req: js.npm.express.Request, res: js.npm.express.Response) -> {
      bar(req);  // errors with js.npm.express.Request should be js.node.http.IncomingMessage For function argument 'foo'
    });

Maybe the extern defs for express.Request in js-kit are wrong? I find it hard to believe that a project in the making for so many years missed something like that. Or maybe I'm missing something?

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