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

Typescript 4.8.2 support #170

Closed
Yurzel opened this issue Aug 30, 2022 · 21 comments · Fixed by #183
Closed

Typescript 4.8.2 support #170

Yurzel opened this issue Aug 30, 2022 · 21 comments · Fixed by #183
Labels
bug Something isn't working

Comments

@Yurzel
Copy link

Yurzel commented Aug 30, 2022

Typescript version 4.8.2 just got released. There is deprecated function used in the plugin.

Functions:
createParameterDeclaration

Error:

TypeError: Invalid arguments
    at Object.createParameterDeclaration (/usr/local/lib/node_modules/@domain/protoc-gen-ts/node_modules/typescript/lib/typescript.js:170461:19)
    at createParameter (/usr/local/lib/node_modules/@domain/protoc-gen-ts/src/rpc.js:154:23)
    at Object.createGrpcInterfaceType (/usr/local/lib/node_modules/@domain/protoc-gen-ts/src/rpc.js:161:31)
    at Object.<anonymous> (/usr/local/lib/node_modules/@domain/protoc-gen-ts/src/index.js:54:32)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

According the line 170461 in typescript package it seems like the function was removed completly.

// Deprecations fall into one of three categories:
//
// - "soft" - Soft deprecations are indicated with the `@deprecated` JSDoc Tag.
// - "warn" - Warning deprecations are indicated with the `@deprecated` JSDoc Tag and a diagnostic message (assuming a compatible host).
// - "error" - Error deprecations are either indicated with the `@deprecated` JSDoc tag and will throw a `TypeError` when invoked, or removed from the API entirely.
@stannedelchev
Copy link

@thesayyn This is happening on my end too with the latest TypeScript 4.8.3.
Installed protoc-gen-ts with npm -g install protoc-gen-ts and then ran protoc -I=. hello.proto --ts_out=.
Error call stack is same as post above. Other protobuf compilers (Go, JS) work fine on the same .proto file.

hello.proto:

syntax = "proto3";

service HelloWorld {
    rpc SayHello (HelloRequest) returns (HelloResponse) {}
}

message HelloRequest {
    string Name = 1;
}

message HelloResponse {
    string Message = 1;
}

Error call stack is the same as previous post:

/usr/lib/node_modules/protoc-gen-ts/node_modules/typescript/lib/typescript.js:170487
            throw new TypeError("Invalid arguments");
            ^

TypeError: Invalid arguments
    at Object.createParameterDeclaration (/usr/lib/node_modules/protoc-gen-ts/node_modules/typescript/lib/typescript.js:170487:19)
    at createParameter (/usr/lib/node_modules/protoc-gen-ts/src/rpc.js:154:23)
    at Object.createGrpcInterfaceType (/usr/lib/node_modules/protoc-gen-ts/src/rpc.js:161:31)
    at Object.<anonymous> (/usr/lib/node_modules/protoc-gen-ts/src/index.js:55:32)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Module._load (node:internal/modules/cjs/loader:838:12)
    at Module.require (node:internal/modules/cjs/loader:1021:19)
    at require (node:internal/modules/cjs/helpers:103:18)

Node.js v18.9.0
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

@thesayyn
Copy link
Owner

Looks like typescript made a breaking change. I'll have look and see what we could use instead without breaking on older version of typescript.

@thesayyn thesayyn added the bug Something isn't working label Sep 24, 2022
@btcSteven
Copy link

image

I solve it ; in your node_modules protoc-gen-ts -> package.json typescript remove ^ use old version

@VanIseghemThomas
Copy link

@btcSteven this worked like a charm, thanks! This is clearly an update that should be done to the package.

@long1eu
Copy link

long1eu commented Nov 7, 2022

Any news on this?

@puzzle9
Copy link

puzzle9 commented Nov 9, 2022

change to "typescript": "4.7.4"

microsoft/TypeScript#50259

@long1eu
Copy link

long1eu commented Nov 9, 2022

@puzzle9 that also doesn't work. I've forked the repo here and this is what I get

node:internal/modules/cjs/loader:988
  throw err;
  ^

Error: Cannot find module '../src/index'
Require stack:
- /usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js' ]
}
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

@puzzle9
Copy link

puzzle9 commented Nov 9, 2022

@puzzle9 that also doesn't work. I've forked the repo here and this is what I get

node:internal/modules/cjs/loader:988
  throw err;
  ^

Error: Cannot find module '../src/index'
Require stack:
- /usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js' ]
}
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

yea

because it is the source code that needs to be compiled before it can be used

simple you can try

mkdir protoc-gen-ts
cd protoc-gen-ts
yarn add protoc-gen-ts
mv node_modules/protoc-gen-ts ./pgt

cd pgt

change package.json "typescript": "^4.3.4" to "typescript": "4.7.4"

yarn
mv bin/protoc-gen-ts.js bin/protoc-gen-ts

remove global protoc-gen-ts and add path this file

try

@Techbinator
Copy link

@puzzle9 that also doesn't work. I've forked the repo here and this is what I get

node:internal/modules/cjs/loader:988
  throw err;
  ^

Error: Cannot find module '../src/index'
Require stack:
- /usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/lib/node_modules/protoc-gen-ts/bin/protoc-gen-ts.js' ]
}
--ts_out: protoc-gen-ts: Plugin failed with status code 1.

yea

because it is the source code that needs to be compiled before it can be used

simple you can try

mkdir protoc-gen-ts
cd protoc-gen-ts
yarn add protoc-gen-ts
mv node_modules/protoc-gen-ts ./pgt

cd pgt

change package.json "typescript": "^4.3.4" to "typescript": "4.7.4"

yarn
mv bin/protoc-gen-ts.js bin/protoc-gen-ts

remove global protoc-gen-ts and add path this file

try

I did the exact same steps but unfortunately the error persist

@dmokel
Copy link

dmokel commented Nov 21, 2022

Hi, guys~has this problem been solved?

@long1eu
Copy link

long1eu commented Nov 21, 2022 via email

@dmokel
Copy link

dmokel commented Nov 21, 2022

me too. so bad

@dmokel
Copy link

dmokel commented Nov 21, 2022

Hi, guys~ I have solved this problem.

you need change package.json "typescript": "^4.3.4" to "typescript": "4.3.4", and remove the node_modules, then npm install or yarn add again.

good luck for you~

@long1eu
Copy link

long1eu commented Nov 21, 2022

Sorry for being dumb, but package.json of this package? Or the one of my package? Also what if I'm using this package as a global dependency?

@dmokel
Copy link

dmokel commented Nov 21, 2022

Sorry for being dumb, but package.json of this package? Or the one of my package? Also what if I'm using this package as a global dependency?

the package.json of this package(protoc-gen-ts)

@dmokel
Copy link

dmokel commented Nov 21, 2022

Sorry for being dumb, but package.json of this package? Or the one of my package? Also what if I'm using this package as a global dependency?

I am using this package as a global dependency too, I change the package (protoc-gen-ts) in my gobal path.

@horacimacias
Copy link

I just did a fresh npm install -g protoc-gen-ts and I'm facing the same issue.

I see the issue is now closed; should this now be working without manual fiddling of the protoc-gen-ts's package.json?

@thesayyn
Copy link
Owner

I just did a fresh npm install -g protoc-gen-ts and I'm facing the same issue.

I see the issue is now closed; should this now be working without manual fiddling of the protoc-gen-ts's package.json?

could you try with npm install -g protoc-gen-ts@next ?

@horacimacias
Copy link

thanks. If I use npm install -g protoc-gen-ts@next I get some deprecation warnings but generation succeeds:

DeprecationWarning: 'createPropertyDeclaration' has been deprecated since v4.8.0. Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createParameterDeclaration' has been deprecated since v4.8.0. Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createConstructorDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createMethodDeclaration' has been deprecated since v4.8.0. Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createClassDeclaration' has been deprecated since v4.8.0. Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createImportDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createModuleDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createGetAccessorDeclaration' has been deprecated since v4.8.0. Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createSetAccessorDeclaration' has been deprecated since v4.8.0. Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createIndexSignature' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createEnumDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createTypeParameterDeclaration' has been deprecated since v4.7.0. Use the overload that accepts 'modifiers'
DeprecationWarning: 'createInterfaceDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.

is that expected? anything to worry about?

@prodbyola
Copy link

prodbyola commented Feb 3, 2023

protoc-gen-ts@next

@horacimacias What's your experience? It built with protoc-gen-ts@next but with the same errors as yours. I'm wondering if you didn't encounter any other issue from your end. I'll only be able to test some hours from now.

@horacimacias
Copy link

I don't think this is creating any issues for me. I am having other issues but I don't think they are related to this, I still need some time to clarify.
If I find this is causing me any problems I'll let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.