Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
prashantbodh099 opened this issue Aug 16, 2024 · 1 comment

Comments

@prashantbodh099
Copy link

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.

@nevi-me
Copy link

nevi-me commented Aug 19, 2024

It looks like you're using "ts-protoc-gen": "^0.15.0", (https://www.npmjs.com/package/ts-protoc-gen) instead of protoc-gen-ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants