“{}”类型的参数不可分配给 'Config<ExpressContext>' 类型的参数。本阿瓦德教程

Argument of type '{}' is not assignable to parameter of type 'Config<ExpressContext>'. Ben Awad tutorial

我目前正在研究 Ben Awad 的 React 和 GraphQL Fullstack 教程。

我的 index.ts 文件中有 运行 这个错误,

当我将鼠标悬停在 const apolloServer = new ApolloServer({})

上时
Argument of type '{}' is not assignable to parameter of type 
'Config<ExpressContext>'.
  Type '{}' is missing the following properties from type 'Config<ExpressContext>': logger, debug, cache, formatError, and 6 more.ts(2345)

供参考,这是我的 index.ts 文件

import "reflect-metadata";
import { MikroORM } from "@mikro-orm/core";
import { __prod__ } from "./constants";
import microConfig from "./mikro-orm.config";
import express from "express";
import { ApolloServer, ExpressContext } from "apollo-server-express";

const main = async () => {
  const orm = await MikroORM.init(microConfig);
  await orm.getMigrator().up();

  const app = express();

  const apolloServer = new ApolloServer({})


  app.listen(4000, () => {
    console.log("running on port 4000");
  });
};

main().catch((err) => {
  console.error(err);
});

code image

试试,

const apolloServer = new ApolloServer({} as Config<ExpressContext>)