-
Notifications
You must be signed in to change notification settings - Fork 764
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
Typescript Type Check Errors #279
Comments
I am not quite able to reproduce. Can you show me your |
The proto is here:
And the entry point is nothing special just a useless import. |
Hm, I am still missing something.
|
Oh, my Typescript version may not match yours
Hm, didn't help. I installed
|
Is the generated js file necessary?Maybe I missed this output file and I will try again. |
Ah yes, they are necessary. So what happened was, there is no typescript support from protobuf yet. The |
I think this should be written into the readme, it's not so easy to understand why I must generate the js file when I only want the ts output. |
Found the problem: function test1(testfunc: (request: {}) => {}) {}
test1((request: Empty) => {return ""}) The tsc will throw this code type imcompaitable error due to the So I suggest to change the generate code like this. function test1(testfunc: (request: any) => {}) {}
test1((request: Empty) => {return ""}) Mainly diffrence is '{}' and 'any'. Or just simply change the request type |
Meanwhile, the second error which describes Here is the typescript type compatibility syntax guide. Hope it's helpful. |
Actually I'd like to be able to use |
Any progress? |
What is this segment of code? Is it from the generated code? Or you wrote that? Sorry I was a little confused on how to reproduce that. |
I wrote that just for test. The generated code still is this issue's content |
As for the environment, I just created a little project by vue-cli and chose typescript as my development language. I don't know whether I could config something to ignore those errors because I am just a newbie for the web. |
I ran into this as well, and i think it is related to typescripts strict mode. If you are interested i can probably come up with a fix and send a PR. :) |
I checked out the repo and updated package.json{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"allowJs": true,
"outDir": "./dist",
"types": ["node"]
},
"include": [
"client.ts",
"echo_pb.js",
"echo_pb.d.ts",
"echo_grpc_web_pb.js",
"echo_grpc_web_pb.d.ts",
"EchoServiceClientPb.ts"
],
"exclude": ["node_modules"]
} When I then ran
|
these problems should be fixed, once a new version is released :) |
thx, I have replaced all grpc-web with this grpc-web although :) |
Some errors exposed when I try to compile my generated typescript code.
One error message here:
And I found the generation code is here:
grpc-web/javascript/net/grpc/web/grpc_generator.cc
Line 395 in 8663199
Another error message here:
And I found the generation code is here:
grpc-web/javascript/net/grpc/web/grpc_generator.cc
Line 438 in 8663199
The part of the wrong generated code shows here:
The
Empty
message defined in proto file likes thismessage Empty {}
FYI: My TS version is 3.0.1
The text was updated successfully, but these errors were encountered: