express-handlebars 在 TypeScript 中抛出类型错误

express-handlebars throwing type error in TypeScript

import express from 'express';
import { engine } from 'express-handlebars';
const app = express();
app.engine("hbs", engine()) // This line trows an error:

我有以下依赖项:

"dependencies": {
  "express": "^4.17.1",
  "express-handlebars": "^6.0.1",
  "morgan": "^1.10.0",
  "@types/express": "^4.17.13",
  "@types/node": "^16.11.7",
  "typescript": "^4.4.4",
  "ts-node": "^10.4.0"
}

我尝试四处寻找,但使用 TypeScript 找不到任何相关信息。

希望有人能帮忙;提前致谢!

如快递文件所述:

Some template engines do not follow this convention, the Consolidate.js library was created to map all of node's popular template engines to follow this convention, thus allowing them to work seamlessly within Express.

这里说的是 Consolidate、Express 和 TypeScript 的示例:

import express from "express";
import cons from "consolidate";

const app = express();
app.engine("html", cons.handlebars);
app.set("view engine", "html");
app.set("views", __dirname + "/views");