connectrpc / connect-es

The TypeScript implementation of Connect: Protobuf RPC that works.
https://connectrpc.com/
Apache License 2.0
1.38k stars 80 forks source link

typescript-language-server shows errors about missing properties on createPromiseClient() #392

Closed 0xd3e closed 1 year ago

0xd3e commented 1 year ago

Describe the bug

The TypeScript Language Server shows errors when calling createPromiseClient(). The generated service is not assignable.

Diagnostics:                                                                                                                                                                                                                                   
 1. Type 'PromiseClient<ServiceType>' is missing the following properties from type 'PromiseClient<{ readonly typeName: "workplus.account.v1alpha1.AccountService"; readonly methods: { readonly createAccount: { readonly name: "CreateAccount 
 "; readonly I: typeof CreateAccountRequest; readonly O: typeof CreateAccountResponse; readonly kind: any; }; readonly generateTemporaryPassword: { ...; }; readonly...': createAccount, generateTemporaryPassword, signIn                      
 2. Argument of type '{ readonly typeName: "workplus.account.v1alpha1.AccountService"; readonly methods: { readonly createAccount: { readonly name: "CreateAccount"; readonly I: typeof CreateAccountRequest; readonly O: typeof CreateAccountR 
 esponse; readonly kind: any; }; readonly generateTemporaryPassword: { ...; }; readonly signIn: { ......' is not assignable to parameter of type 'ServiceType'.

To Reproduce

import { AccountService } from "pb/workplus/account/v1alpha1/service_connectweb"
import {
  createPromiseClient,
  createConnectTransport
} from "@bufbuild/connect-web"

import type { PromiseClient } from '@bufbuild/connect-web'

interface API {
  account: PromiseClient<typeof AccountService>
}

const transport = createConnectTransport({
  baseUrl: "localhost:50100"
})

export const api: API = {
  account: createPromiseClient(AccountService, transport)
}

Environment (please complete the following information):

0xd3e commented 1 year ago

It works now. It seems that I missed to install @bufbuild/protobuf.