title: How do you generate typings for protobuf files for use with GRPC?
body: <p>I am trying to use GRPC with TypeScript, and I am trying to make sure I have all the types set (rather than just adding my own mapping or using <code>any</code>.</p>
  <p>I've gotten as far as with problems I am experiencing noted in the comments.</p>
  <pre class="lang-js prettyprint-override"><code>import { Server, loadPackageDefinition } from &quot;grpc&quot;;
  import { loadSync } from &quot;@grpc/proto-loader&quot;;
  
  const packageDefinition = loadSync(__dirname + &quot;/protos/artifact.proto&quot;);
  const artifacts = loadPackageDefinition(packageDefinition).artifacts;
  
  // what are the types here?
  function SignedUrlPutObject(call, callback) {
  }
  
  const server = new Server();
  // There's no ArtifactUpload defined in artifacts
  server.addService(artifacts.ArtifactUpload.service, { SignedUrlPutObject })
  
  </code></pre>
  <p>Another approach I tried was to use <code>pbjs</code> and <code>pbts</code>.</p>
  <pre class="lang-json prettyprint-override"><code>&quot;protobuf&quot;: &quot;pbjs -t static-module -w commonjs -o protos.js protos/artifact-upload.proto &amp;&amp; pbts -o protos.d.ts protos.js&quot;,
  </code></pre>
  <p>This generated the typings file, but I can't get it to work with grpc.  Here's a github issue I found that may be related <a href="https://github.com/protobufjs/protobuf.js/issues/1381" rel="nofollow noreferrer">https://github.com/protobufjs/protobuf.js/issues/1381</a></p>