Closed CrazyFlasher closed 2 years ago
issue with haxe 4.2.3 on this line:
(next: () -> Void)();
Just re-ran the express example with 4.2.3 and latest @types/express and didn't have the error so cannot repro – my steps were (in an empty directory):
npm i @types/express express dts2hx
npx dts2hx express
And add the following filesbuild.hxml
--main Main
--js main.js
--library express
Main.hx
function main() {
/**
Express Hello World Example with Router
For a discussion on this example see this thread:
https://community.haxe.org/t/how-does-one-use-routes-in-express/2701
**/
var app = Express.call();
var port = 3000;
app.get('/', (req, res, next) -> res.send('Hello World! <a href="/birds">/birds</a>'));
app.listen(port, () -> trace('Example app listening at http://localhost:${port}'));
app.get('/route', (req, res, next) -> res.send('Example route'));
var router = express.Router.call_();
// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
trace('Time: ' + Date.now());
(next: () -> Void)();
return null;
});
// define the home page route
router.get('/', (req, res, next) -> {
res.send('Birds home page');
});
// define the about route
router.get('/about', (req, res, next) -> {
res.send('About birds');
});
app.use('/birds', router.call);
}
Is yours the same? Maybe the haxe code is a little different?