question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove Unused bindings for Annotations Imports?

See original GitHub issue

My .proto file includes imports that are never used by the generated JS client - eg. import google/api/annotations.proto import "protoc-gen-swagger/options/annotations.proto"

I was able to generate the JS client with protoc-get-grpc-web, however, the generated code includes those imports even though they are not used by the client:

var google_api_annotations_pb = require('../../google/api/annotations_pb.js')
var protoc$gen$swagger_options_annotations_pb = require('../../protoc-gen-swagger/options/annotations_pb.js')
// Lint Errors:
>>> var `google_api_annotations_pb` is declared but its value is never read
>>> var `google_protobuf_empty_pb` is declared but its value is never read

Is there something in place to prevent unused bindings from being included in the generated code?

Similar issue with grpc-gateway code gen: https://github.com/grpc-ecosystem/grpc-gateway/issues/310

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:17
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
fr33kvanderwandcommented, Mar 22, 2021

would love to see some progress on this one, since it’s a really annoying issue

5reactions
josdotsocommented, Feb 18, 2020

Any updates on this? I’m new to grpc-web, my backend is in go, and I don’t know what to do about this. (e.g. ../../google/api/annotations_pb.js isn’t even a file path that would be within my repo.

Did you work around this somehow @gtalarico ?

I ended up with lines like this in my Makefile:

ls -1 api/pb/*.js | xargs sed -i '/google_api_annotations_pb =/d'
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Remove annotation" quick fix doesn't remove unused import
"Remove annotation" quick fix doesn't remove unused import. Open the following code ... NotNull; import org.jetbrains.annotations.Nullable; public class Foo ...
Read more >
org.eclipse.jdt.core.dom.rewrite.ImportRewrite.addStaticImport java ...
public String addStaticImport(IBinding binding) { return ... If a import for a type is recorded to be removed, this record is discarded instead....
Read more >
Guice binding not done with @Named annotation
Now if I remove the @Named annotation, it works. The getName() method is succesfully called. When adding the @Named annotation though, getName() ...
Read more >
Invalid 'import is never used' warning for annotations - Eclipse
And if I organize the imports, the annotation import is removed and my ... your sample works fine for me too, no unused...
Read more >
Common issues and solutions - mypy 0.991 documentation
Functions that do not have any annotations (neither for any argument nor for the ... In some cases, linters will complain about unused...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found