ApolloServer 4 - 预期 0 个参数,但实际得到 1 个 - Typescript 错误。

3
创建新的ApolloServer对象时出现预期0个参数但实际得到1个参数的TypeScript错误。根据文档,它应该接受一个参数,尽管代码执行没有错误,但不确定为什么会收到这个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}`);

你找到问题了吗? - Hemant
还没有。你也遇到同样的问题吗? - RRR
是的,连同“类型'ApolloServer'上不存在属性'start'。” - Hemant
1个回答

1

我找到了这个问题的原因,是由于 vscode 使用的 TypeScript 版本与项目中使用的版本不匹配导致的。请检查 vscode 使用的版本并尝试更新它以使其与项目匹配。

enter image description here

请按如下步骤更新设置中的 vscode 版本。

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接