-
Notifications
You must be signed in to change notification settings - Fork 769
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
Failed to compile. 'proto' is not defined (also 'COMPILED') #447
Comments
I've tried to add
|
Was able to bypass this problem by adding
|
And I was able to bypass |
Sorry for the late reply. TypeScript support is 'experimental' right now. We would definitely welcome contributions. Seems like you have resolved your issue? |
Well, I wouldn't call it "resolved" - I basically disabled typescript compiler check and eslint check. But true, it made project compile |
@argoyb I have a similar setup as you (CRA, typescript, grpc-web). I generate the grpc-web related files into a separate github project, then include the generated files into my "main" project via hope this helps |
Is bypassing solution ? |
Thanks, (For development-purposes) i created a separate npm package "<my-react-project>-proto-src" right next to "<my-react-project>"
my grpc-web options are: |
Btw, I get the same compile errors and I am not using Typescript. If I simply edit the generated files by adding the /* eslint-disable */ at the top just like @argoyb . Be nice if there was some code gen flag to emit this. |
After adding /* eslint-disable */ to the start of the generated code, got rid of the compilation errors. |
I was able to bypass the error by inserting a "fake" object at the top of the foo_pb.js file as such:
NOTE: this only works for files generated for protos with no imports. If imports are present, the namespace resolution fails. It seems clear to me that the Closure-style structure of a Is there some form of preamble that should be included as well? I.e. is there something being overlooked that provides the missing symbols? This all works for me when compiled because it can resolve symbols before actually being dealt with "as javascript"'... but the codegen herein is advertised as "just working" without an intelligent compilation step. As generated, the proto module currently isn't valid javascript and will fail with a |
Maybe a better workaround is to ignore _pb.js files for eslint, which doesn't require modifying the generated files every time (that gets old really fast). Create a file called .env in your project root containing only
Note that this is currently flagged experimental in the docs. Sources: https://create-react-app.dev/docs/setting-up-your-editor/ |
@alpaka To clarify: for what I'm seeing, eslint is just warning of a deeper issue. This is not strictly an issue in eslint. Ignoring it at that layer prevents the warnings but does not prevent failure when the files are loaded in the browser. The issue is that there is no included code which initializes the proper objects/namespaces. This happens for me when the _pb.js files are just loaded without any special symbol resolution (as seems to run for me when I compile). |
From reading earlier in this thread, I have found the full workaround to be the following:
For the second step, it's easier to do this in a script. You can use something similar to what was suggested here.
Hopefully a proper solution arises in the future |
Hope this has been fixed by #752 |
Given an initial
issues that were seen in the |
I can also confirm, the generated ts file for a service has the |
Unfortunately the |
@stanley-cheung who is the generation of that file controlled by? |
I've solved this issue by adding EXTEND_ESLINT=true in the .env file |
I'm using create-react-app with typescript and grpc-web, grpc & proto generated with command:
App is not able to start, it throws tons of errors of form
The text was updated successfully, but these errors were encountered: