未知错误,本·阿瓦德的"Fullstack React GraphQL TypeScript Tutorial"



我在Ben Awad的" Fullstack React GraphQL TypeScript教程"项目中工作。

在索引中。t,我的大部分代码都用红色突出显示。
我的代码
当我将鼠标悬停在代码

上时,出现以下错误
Argument of type '{ schema: GraphQLSchema; context: ({ req, res }: ExpressContext) => 
MyContext; plugins: any[]; }' is not assignable to parameter of type 
'Config<ExpressContext>'.
Type '{ schema: GraphQLSchema; context: ({ req, res }: ExpressContext) => MyContext; 
plugins: any[]; }' is missing the following properties from type 
'Config<ExpressContext>': logger, debug, cache, formatError, and 6 more.ts(2345)

Typescript报错,因为它期望的类型是Config<ExpressContext>,而接收到的类型是{ schema: GraphQLSchema; context: ({ req, res }: ExpressContext) => MyContext; plugins: any[]; }

假设您不关心丢失的属性,您可以将其强制转换为Config<ExpressContext>:

{ schema: GraphQLSchema; context: ({ req, res }: ExpressContext) => MyContext; plugins: any[]; } as Config<ExpressContext>.

最新更新