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

unused parameters in the empty.ts are causing TypeScript check errors #608

Closed
tidycode opened this issue Nov 28, 2023 · 6 comments
Closed

Comments

@tidycode
Copy link

This empty.ts was auto generated from protobuf file "google/protobuf/empty.proto" (package "google.protobuf", syntax proto3)

the error is in the function internalBinaryRead
image

    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Empty): Empty {
        return target ?? this.create();
    }

if run script vue-tsc --noEmit --skipLibCheck
It will cause ts-check error
'reader' is declared but its value is never read.
'length' is declared but its value is never read.
'options' is declared but its value is never read.

@danielvandenberg95
Copy link

It's not only in empty.ts. It's in any proto message without members. A solution would be to prefix unused variables with _.

Use-case: I've got multiple empty types because I expect to add members in the future.

@danielvandenberg95
Copy link

#609

@danielvandenberg95
Copy link

As timostamm suggested there, generate proto with --ts_opt ts_nocheck.

@tidycode
Copy link
Author

As timostamm suggested there, generate proto with --ts_opt ts_nocheck.

thanks ,but where is the --ts_opt that I can add?
I use buf.gen.yaml

version: v1
plugins:
  - plugin: buf.build/community/timostamm-protobuf-ts:v2.9.1
    out: ./ts

if run
buf generate --ts_opt ts_nocheck
will throw error: unknown flag: --ts_opt

@timostamm
Copy link
Owner

See the documentation here.

version: v1
plugins:
  - plugin: buf.build/community/timostamm-protobuf-ts:v2.9.1
    out: ./ts
    opt: ts_nocheck

For multiple plugin options, use:

version: v1
plugins:
  - plugin: ...
    out: ...
    opt: 
      - ts_nocheck
      - other_option

@tidycode
Copy link
Author

tidycode commented Dec 1, 2023

opt: ts_nocheck

Many thanks, now it works!
empty.ts before

// @generated by protobuf-ts 2.9.1 with parameter ts_nocheck
// @generated from protobuf file "google/protobuf/empty.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
......

empty.ts after

// @generated by protobuf-ts 2.9.1 with parameter ts_nocheck
// @generated from protobuf file "google/protobuf/empty.proto" (package "google.protobuf", syntax proto3)
// tslint:disable
// @ts-nocheck
......

and also thanks @danielvandenberg95 I think #609. is a good PR

@tidycode tidycode closed this as completed Dec 1, 2023
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

3 participants