blokur / grpc-ts-demo

🎵 Demo of a gRPC client and server implementation in TypeScript
MIT License
124 stars 30 forks source link

error TS2345: Argument of type `'ISchoolService' `is not assignable to parameter of type `'ServiceDefinition<UntypedServiceImplementation>'` #29

Closed khteh closed 1 month ago

khteh commented 1 month ago

I generate grpc Typescript code with:

"proto": "npx grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./grpc/client --grpc_out=./grpc/client --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` -I ./grpc/proto ./grpc/proto/*.proto && npx grpc_tools_node_protoc --plugin=protoc-gen-ts=`which protoc-gen-ts` --ts_out=./grpc/client -I ./grpc/proto ./grpc/proto/*.proto",

and hit the following error:

Services/SchoolService.ts:205:23 - error TS2345: Argument of type 'ISchoolService' is not assignable to parameter of type 'ServiceDefinition<UntypedServiceImplementation>'.
  Index signature for type 'string' is missing in type 'ISchoolService'.

205     server.addService(SchoolService, new ServerImpl());

Environment