js-deprecated icon indicating copy to clipboard operation
js-deprecated copied to clipboard

'"@solana/web3.js"' has no exported member 'TransactionCtorFields'.

Open HAL68000 opened this issue 2 years ago • 2 comments

Hi everyone, I am trying to integrate metaplex to my angular project but on import I've got the following error:

Error: node_modules/@metaplex/js/lib/transactions/PayForFiles.d.ts:3:21 - error TS2305: Module '"@solana/web3.js"' has no exported member 'TransactionCtorFields'.

To Reproduce Steps to reproduce the behavior:

  1. installl the metaplex library with: npm install @metaplex/js
  2. add this to your actual code import { Connection, programs } from '@metaplex/js'; const { metadata: { Metadata } } = programs;
  3. compile
  4. See error
...
Error: node_modules/@metaplex/js/lib/transactions/MintTo.d.ts:1:21 - error TS2305: Module '"@solana/web3.js"' has no exported member 'TransactionCtorFields'.

1 import { PublicKey, TransactionCtorFields } from '@solana/web3.js';
                    ~~~~~~~~~~~~~~~~~~~~~


Error: node_modules/@metaplex/js/lib/transactions/PayForFiles.d.ts:3:21 - error TS2305: Module '"@solana/web3.js"' has no exported member 'TransactionCtorFields'.

3 import { PublicKey, TransactionCtorFields } from '@solana/web3.js';
                    ~~~~~~~~~~~~~~~~~~~~~
...

Notes Looks like that TransactionCtorFields is deprecated. I found some reference here: https://solana-labs.github.io/solana-web3.js/modules.html#TransactionCtorFields_DEPRECATED and the relative issue on solana labs here: https://github.com/solana-labs/solana/issues/23949

Any suggestion on how solve the issue? Thank you all in advance.

HAL68000 avatar May 25 '22 00:05 HAL68000

I am using https://www.typescriptlang.org/tsconfig#skipLibCheck until this issue is resolved. I think the problem is that @solana/web3.js is a package dependency instead of peer dependency. If it would be a peer dep, then we could downgrade @solana/web3.js package to a version that has TransactionCtorFields. I just don't understand why the devs at @solana/web3.js decided to rename the TransactionCtorFields to TransactionCtorFields_DEPRECATED. This is not how you deprecate anything

speculees avatar Jun 01 '22 08:06 speculees

Sorry about this. The real problem here is that we export way too much stuff from web3.js, and the only reason we export a type like this that's fundamentally internal is because of TypeDoc (the thing that generates our documentation). I plan not to make this mistake again when we rewrite web3.js.

I will send a PR now to fix this once and for all.

steveluscher avatar Jun 02 '22 02:06 steveluscher