tatethurston / TwirpScript

A protobuf RPC framework for JavaScript and TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIN_SUPPORTED_VERSION_0_0_34 is declared but its value is never read

PatriciaHudakova opened this issue Β· comments

Heya,

I have upgraded to v0.0.39 (thank you for all your work πŸŽ‰ ), and I've noticed this new field being generated with the new version. I understand it acts as a backwards compatibility check which is really useful, but because our ts compiler settings are quite strict (specifically noUnusedParameters is set to true), the project compilation fails. Commenting this out in the generated files causes the rest of the library work as intended.

I recognise the importance of this check, but I was wondering if there was a way around it (other than commenting it out)? Maybe using this variable in a benign way?

I'm not sure if dropping the noUnusedParameters setting in ts config to make this work is a good solution

Thank you!

Or would it be possible to generate that file with @ts-ignore on the offensive line?

Hey @PatriciaHudakova thanks for reporting this. I've been on the fence about MIN_SUPPOTED_VERSION_X.

It's nice that it's a simple way to ensure compatibility at compile time, rather than breaking at runtime on mismatched TwirpScript / .pb.ts files. That said, I'm not sure how likely a mismatch is in practice. I expect most clients will run yarn twirpscript frequently, and the version mismatch is a more likely scenario for other protobuf workflows where the protoc compiler is invoked directly on a proto file.

As a design goal, TwirpScript should always work with the strictest TypeScript compiler settings. That won't hold true for estlint / prettier -- I think it probably makes sense to omit code generation from those tools.

I think exporting MIN_SUPPORTED_VERSION_X will let us keep the check while not being flagged by the TS compiler.