I am reading a tutorial on Express and Node.js and trying to convert the JavaScript to TypeScript.
The code includes
var handlebars = require("express-handlebars")
.create({ defaultLayout: 'main' });
which I have translated to TypeScript as is.
Is there a more idiomatic TypeScript using import ... as (from ECMAScript 6) or import handlebars = ... that accomplishes the same thing (including the call to create)?
I have tried the following:
import handlebars = require("express-handlebars")
handlebars.create({ defaultLayout: 'main' })
but I get a runtime error from nodejs on the later line
app.engine('handlebars', handlebars.engine)
saying Error: callback function required.
I assume that the error comes because the object has not been properly created.
import * as handlebars from 'express-handlebars'handlebars.create(...)as the next line, I get the nodejs error indicated above.engineexported. I would guess it isimport * as handlebars from 'express-handlebars'; var engine = handlebars.create(...).engine; app.engine('handlebars, engine)