tronweb-typescript icon indicating copy to clipboard operation
tronweb-typescript copied to clipboard

Cannot find module '@types/tronweb' or its corresponding type declarations.

Open altbit opened this issue 2 years ago • 13 comments

The project looks broken.

According to the package.json

...
   "license": "MIT",
  "main": "index.js",
  "name": "@daochild/tronweb-typescript",
...

there are no types defined and main file is index.js which doesn't exist in the package: image

Look at the @types/uuid as a simple example how it should be done:

...
   "license": "MIT",
  "main": "",
  "name": "@types/uuid",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
    "directory": "types/uuid"
  },
  "scripts": {},
  "typeScriptVersion": "3.8",
  "types": "index.d.ts",
...

altbit avatar May 18 '23 13:05 altbit

It was tested on node.js 16 and using with Goland IDE, types have been displayed.

daochild avatar May 19 '23 18:05 daochild

Same issue too, how can i fix it @daochild ?

uuhnaut69 avatar Aug 16 '23 14:08 uuhnaut69

Same issue too, how can i fix it @daochild ?

Attempt check the next code example, maybe it will be helpful https://github.com/daochild/tronweb-typescript/blob/main/src/tests/test.ts#L9

And let me know if it not.

daochild avatar Aug 17 '23 17:08 daochild

I tried but not working

uuhnaut69 avatar Aug 18 '23 08:08 uuhnaut69

@uuhnaut69 @altbit Hi it should have been fixed for now. Could you check please?

daochild avatar Sep 22 '23 09:09 daochild

Not working, can not reference to tronweb type

uuhnaut69 avatar Oct 05 '23 02:10 uuhnaut69

Hello, I had the same issue. Fixed it by adding @daochild/tronweb-typescript to the types section in tsconfig.json as following:

"types": [
      "@daochild/tronweb-typescript"
],

My package.json:

{
  "devDependencies": {
    "@daochild/tronweb-typescript": "^1.1.2",
    "typescript": "^5.3.3"
  },
  "dependencies": {
    "tronweb": "^5.3.1"
  }
}

Also, now there is no need for tripple-slash reference. I think there is a better way, but I couldn't find one.

Russia9 avatar Jan 02 '24 20:01 Russia9

same issue but it doesn't work for me. installed @daochild/tronweb-typescript and added it to type section in tsconfig.json. double checked package.json file too.

please let me know what i should do.

StormyTalents avatar Jan 31 '24 23:01 StormyTalents

the solution is to add to tsconfig.json

  "include": [
    "src",
    "./node_modules/@daochild/tronweb-typescript/dist/index.d.ts"
  ],

rtomas avatar Jul 13 '24 03:07 rtomas

Update to v1.2.2 Read Usage in README.md

daochild avatar Sep 11 '24 10:09 daochild

Still not working in my side. I'm using node v20.16.0. I already built tronweb script in node.js but can't convert to typescript. /root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:859 return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ Unable to compile TypeScript: swap_last.ts:2:21 - error TS7016: Could not find a declaration file for module 'tronweb'. '/root/dev/Tron-volume-script/node_modules/tronweb/dist/TronWeb.node.js' implicitly has an 'any' type. Try npm i --save-dev @types/tronwebif it exists or add a new declaration (.d.ts) file containingdeclare module 'tronweb';`

2 import TronWeb from 'tronweb'; ~~~~~~~~~ swap_last.ts:23:75 - error TS7006: Parameter 'error' implicitly has an 'any' type.

23 const tx = await tronWeb.trx.sendTransaction(toAddress, amount).catch(error => { ~~~~~

at createTSError (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:863:19)
at getOutput (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1077:36)
at Object.compile (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1433:41)
at Module.m._compile (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Object.require.extensions.<computed> [as .ts] (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) {

diagnosticCodes: [ 7016, 7006 ] }`

This is error. I followed the readme but not working in my side. How can I solve this?

winer328 avatar Sep 12 '24 21:09 winer328

Still not working in my side. I'm using node v20.16.0. I already built tronweb script in node.js but can't convert to typescript. /root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:859 return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ Unable to compile TypeScript: swap_last.ts:2:21 - error TS7016: Could not find a declaration file for module 'tronweb'. '/root/dev/Tron-volume-script/node_modules/tronweb/dist/TronWeb.node.js' implicitly has an 'any' type. Try npm i --save-dev @types/tronwebif it exists or add a new declaration (.d.ts) file containingdeclare module 'tronweb';`

2 import TronWeb from 'tronweb'; ~~~~~~~~~ swap_last.ts:23:75 - error TS7006: Parameter 'error' implicitly has an 'any' type.

23 const tx = await tronWeb.trx.sendTransaction(toAddress, amount).catch(error => { ~~~~~

at createTSError (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:863:19)
at getOutput (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1077:36)
at Object.compile (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1433:41)
at Module.m._compile (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Object.require.extensions.<computed> [as .ts] (/root/.nvm/versions/node/v20.16.0/lib/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) {

diagnosticCodes: [ 7016, 7006 ] }`

This is error. I followed the readme but not working in my side. How can I solve this?

It doesn't work only with this method or with any other? Try add custom type as in read me. Or resolve implicity types in tsconfig.

daochild avatar Sep 12 '24 22:09 daochild

Cool. Thanks for your support. I hope your business will be success. Best regards.

winer328 avatar Sep 17 '24 08:09 winer328