Open sharifzadesina opened 1 month ago
It is possible to import types like this:
import type { Transaction as TronTransaction } from "tronweb/lib/esm/types/Transaction.js";
import type { TransferContract, TriggerSmartContract } from "tronweb/lib/esm/types/Contract.js";
import type { Block as TronBlock } from "tronweb/lib/esm/types/APIResponse.js";
But when you try to import ContractType
, because it is not a type, we get an error:
import { ContractType } from "tronweb/lib/esm/types/Contract.js";
console.log(ContractType.AccountCreateContract);
The code above fails with error:
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/esm/types/Contract.js' is not defined by "exports" in /home/sina/Projects/pouch-js/node_modules/tronweb/package.json imported from /home/sina/Projects/pouch-js/src/test.ts
at new NodeError (node:internal/errors:406:5)
at exportsNotFound (node:internal/modules/esm/resolve:268:10)
at packageExportsResolve (node:internal/modules/esm/resolve:598:9)
at packageResolve (node:internal/modules/esm/resolve:772:14)
at moduleResolve (node:internal/modules/esm/resolve:838:20)
at defaultResolve (node:internal/modules/esm/resolve:1043:11)
at nextResolve (node:internal/modules/esm/hooks:833:28)
at h (file:///home/sina/Projects/pouch-js/node_modules/tsx/dist/esm/index.mjs?1716925776637:2:1939)
at j (file:///home/sina/Projects/pouch-js/node_modules/tsx/dist/esm/index.mjs?1716925776637:2:3184)
at async nextResolve (node:internal/modules/esm/hooks:833:22) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v20.8.1
Because ContractType is an enum type and if you import it without type
key word, it will generate the import statement in the output file. But we don't add this subpath in our package.json as we did't know that anyone will use this object. We are consider to add this subpath in our next version. For now, you can copy the code in the file and use it.
Thank you. God bless πππ«‘πΊπΈ
Zachariah M Evans
On Wed, May 29, 2024 at 3:50β―AM start940315 @.***> wrote:
Because ContractType is an enum type and if you import it without type key word, it will generate the import statement in the output file. But we don't add this subpath in our package.json as we did't know that anyone will use this object. We are consider to add this subpath in our next version. For now, you can copy the code in the file and use it.
β Reply to this email directly, view it on GitHub https://github.com/tronprotocol/tronweb/issues/520#issuecomment-2136885162, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDV43C2YSWJCNO6VLD4YCE3ZEWJHFAVCNFSM6AAAAABINMZA5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZWHA4DKMJWGI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@start940315 Of course it is not a type, so it throws an error. please on the next update export types also.
Just the title. related to v6.