ApolloServer 4 - 预期 0 个参数但得到 1 个 - 打字稿错误

问题描述 投票:0回答:1

在创建新的 ApolloServer 对象时得到预期的 0 个参数但得到 1 个 - Typescript 错误。根据文档,它应该接受一个参数,代码执行时也没有错误,但不确定为什么会从打字稿中收到此警告。

import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { schema } from "./api/schema";
import ContextValue from "./api/context";

const server = new ApolloServer({
  schema,
});

const { url } = await startStandaloneServer(server, {
  listen: { port: 4000 },
  context: async ({ req }) => new ContextValue({ req, server }),
});

console.log(`🚀  Server ready asst: ${url}`);
typescript graphql apollo-server
1个回答
0
投票

我发现了这个问题,这是由于 vscode 与项目使用的打字稿版本不匹配而发生的。查看vscode使用的版本,不匹配尝试更新

在如下设置中更新 vscode 版本。

© www.soinside.com 2019 - 2024. All rights reserved.