Skip to content

Generated Typescript files are using 'grpc' instead of '@grpc/grpc-js' #265

@prashantbodh099

Description

@prashantbodh099

Hi Team!

In our new angular application, we are using gRPC for client-server communication. We wrote a few proto files and tried to compile them into typescript files using protoc-gen-ts module. But the generated d.ts files are importing 'grpc' instead of '@grpc/grpc-js' which is failing the build process of app.

Here is a snippet of the generated file (device_management_grpc_pb.d.ts)

// package: device_management
// file: device_management.proto

/* tslint:disable */
/* eslint-disable */

import * as grpc from "grpc";
import * as device_management_pb from `"./device_management_pb";``

We are using the following commands to compile the proto(s) into typescript files:

PYTHON="python3.12"
PROTOC="protoc"
GRPC_TOOLS_NODE_PROTOC="../node_modules/.bin/grpc_tools_node_protoc"
PROTOC_GEN_TS="../node_modules/.bin/protoc-gen-ts"
GRPC_TOOLS_NODE_PROTOC_PLUGIN="../node_modules/.bin/grpc_tools_node_protoc_plugin"
OUT_DIR="../compiled"

"$GRPC_TOOLS_NODE_PROTOC" \
    --plugin="protoc-gen-grpc=$GRPC_TOOLS_NODE_PROTOC_PLUGIN" \
    --grpc_out="grpc_js:${OUT_DIR}/ts" \
    --js_out="import_style=commonjs,binary:${OUT_DIR}/ts" \
    -I=. \
    "${file_list[@]}"

"$GRPC_TOOLS_NODE_PROTOC" \
    --plugin="protoc-gen-ts=${PROTOC_GEN_TS}" \
    --ts_out="${OUT_DIR}/ts" \
    -I=. \
    "${file_list[@]}"``

Further information about the environment are
OS : Ubuntu 20.04.6 LTS
Node : v20.15.1
"@grpc/grpc-js": "^1.9.9",
"grpc_tools_node_protoc_ts": "^5.3.3",
"grpc-tools": "^1.12.4",
"ts-protoc-gen": "^0.15.0",
"typescript": "5.5.4"

Is there any way i can get "@grpc/grpc-js" in generated d.ts files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions