1

I am receiving all these errors when working with TypeScript and Metaplex SDK? Anyone know why?


2 import BN from 'bn.js';
         ~~

  node_modules/@types/bn.js/index.d.ts:598:1
    598 export = BN;
        ~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/js/dist/types/types/BigNumber.d.ts:3:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag

3 import BN from 'bn.js';
         ~~

  node_modules/@types/bn.js/index.d.ts:598:1
    598 export = BN;
        ~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/js/dist/types/types/DateTime.d.ts:1:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag

1 import BN from 'bn.js';
         ~~

  node_modules/@types/bn.js/index.d.ts:598:1
    598 export = BN;
        ~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/js/dist/types/utils/Disposable.d.ts:1:13 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/eventemitter3/index"' can only be default-imported using the 'esModuleInterop' flag

1 import type EventEmitter from 'eventemitter3';
              ~~~~~~~~~~~~

  node_modules/eventemitter3/index.d.ts:134:1
    134 export = EventEmitter;
        ~~~~~~~~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/js/dist/types/utils/GpaBuilder.d.ts:4:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag

4 import BN from 'bn.js';
         ~~

  node_modules/@types/bn.js/index.d.ts:598:1
    598 export = BN;
        ~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/js/dist/types/utils/Task.d.ts:1:13 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/eventemitter3/index"' can only be default-imported using the 'esModuleInterop' flag

1 import type EventEmitter from 'eventemitter3';
              ~~~~~~~~~~~~

  node_modules/eventemitter3/index.d.ts:134:1
    134 export = EventEmitter;
        ~~~~~~~~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/mpl-auction-house/node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:2:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag

2 import BN from 'bn.js';
         ~~

  node_modules/@types/bn.js/index.d.ts:598:1
    598 export = BN;
        ~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/struct.d.ts:41:5 - error TS2416: Property 'write' in type 'BeetStruct<Class, Args>' is not assignable to the same property in base type 'ScalarFixedSizeBeet<Class, Partial<Class>>'.
  Type '(buf: Buffer, offset: number, value: Args) => void' is not assignable to type '(buf: Buffer, offset: number, value: Class | Partial<Class>) => void'.
    Types of parameters 'value' and 'value' are incompatible.
      Type 'Class | Partial<Class>' is not assignable to type 'Args'.
        'Args' could be instantiated with an arbitrary type which could be unrelated to 'Class | Partial<Class>'.

41     write(buf: Buffer, offset: number, value: Args): void;
       ~~~~~

  node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/struct.d.ts:15:33
    15 export declare class BeetStruct<Class, Args = Partial<Class>> implements ScalarFixedSizeBeet<Class> {
                                       ~~~~~
    This type parameter might need an `extends Args` constraint.

node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:2:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag

2 import BN from 'bn.js';
         ~~

  node_modules/@types/bn.js/index.d.ts:598:1
    598 export = BN;
        ~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:194:81 - error TS2677: A type predicate's type must be assignable to its parameter's type.
  Type 'FixedSizeBeet<T, Partial<T>>' is not assignable to type 'Beet<T, V>'.
    Type 'ScalarFixedSizeBeet<T, Partial<T>>' is not assignable to type 'Beet<T, V>'.
      Type 'ScalarFixedSizeBeet<T, Partial<T>>' is not assignable to type 'ElementCollectionFixedSizeBeet<T, V>'.
        Type 'ScalarFixedSizeBeet<T, Partial<T>>' is not assignable to type 'BeetReadWrite<T, V>'.
          Types of property 'write' are incompatible.
            Type '(buf: Buffer, offset: number, value: T | Partial<T>) => void' is not assignable to type '(buf: Buffer, offset: number, value: T | V) => void'.
              Types of parameters 'value' and 'value' are incompatible.
                Type 'T | V' is not assignable to type 'T | Partial<T>'.
                  Type 'V' is not assignable to type 'T | Partial<T>'.

194 export declare function isFixedSizeBeet<T, V = Partial<T>>(x: Beet<T, V>): x is FixedSizeBeet<T>;
                                                                                    ~~~~~~~~~~~~~~~~

  node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:194:44
    194 export declare function isFixedSizeBeet<T, V = Partial<T>>(x: Beet<T, V>): x is FixedSizeBeet<T>;
                                                   ~~~~~~~~~~~~~~
    This type parameter might need an `extends T | Partial<T>` constraint.

node_modules/@solana/wallet-adapter-base/lib/types/adapter.d.ts:2:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/eventemitter3/index"' can only be default-imported using the 'esModuleInterop' flag

2 import EventEmitter from 'eventemitter3';
         ~~~~~~~~~~~~

  node_modules/eventemitter3/index.d.ts:134:1
    134 export = EventEmitter;
        ~~~~~~~~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/arbundles/file/file.d.ts:2:28 - error TS2307: Cannot find module 'fs/promises' or its corresponding type declarations.

2 import { FileHandle } from "fs/promises";
                             ~~~~~~~~~~~~~

node_modules/arbundles/file/FileBundle.d.ts:5:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/arweave/node/index"' can only be default-imported using the 'esModuleInterop' flag

5 import Arweave from "arweave";
         ~~~~~~~

  node_modules/arweave/node/index.d.ts:2:1
    2 export = Arweave;
      ~~~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/arbundles/src/Bundle.d.ts:4:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/arweave/node/index"' can only be default-imported using the 'esModuleInterop' flag

4 import Arweave from "arweave";
         ~~~~~~~

  node_modules/arweave/node/index.d.ts:2:1
    2 export = Arweave;
      ~~~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/arbundles/src/BundleInterface.d.ts:3:8 - error TS1259: Module '"/Users/lonestardev/GrizzlyThon/GirzzleyThon_Wallet_Layer_v1/node_modules/arweave/node/index"' can only be default-imported using the 'esModuleInterop' flag

3 import Arweave from "arweave";
         ~~~~~~~

  node_modules/arweave/node/index.d.ts:2:1
    2 export = Arweave;
      ~~~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.


Found 15 errors in 14 files.

Errors  Files
     1  node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:2
     1  node_modules/@metaplex-foundation/js/dist/types/types/BigNumber.d.ts:3
     1  node_modules/@metaplex-foundation/js/dist/types/types/DateTime.d.ts:1
     1  node_modules/@metaplex-foundation/js/dist/types/utils/Disposable.d.ts:1
     1  node_modules/@metaplex-foundation/js/dist/types/utils/GpaBuilder.d.ts:4
     1  node_modules/@metaplex-foundation/js/dist/types/utils/Task.d.ts:1
     1  node_modules/@metaplex-foundation/mpl-auction-house/node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:2
     1  node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/struct.d.ts:41
     2  node_modules/@metaplex-foundation/mpl-candy-machine-core/node_modules/@metaplex-foundation/beet/dist/types/src/types.d.ts:2
     1  node_modules/@solana/wallet-adapter-base/lib/types/adapter.d.ts:2
     1  node_modules/arbundles/file/file.d.ts:2
     1  node_modules/arbundles/file/FileBundle.d.ts:5
     1  node_modules/arbundles/src/Bundle.d.ts:4
     1  node_modules/arbundles/src/BundleInterface.d.ts:3

1 Answer 1

0

I've ran into this a couple times, and from what I understand typescript is basically double checking the node packages for errors. Which is a good thing but annoying at times. Though the case can be made that that its not technically your problem it's the package creators' problem. Either way it could technically affect your software.

Skip the check via tsconfig

You can skip this check by adding the following to your compiler options in your tsconfig

{
  "compilerOptions": {
    // ...other options,
    "skipLibCheck": true
  },
}

You can see the config option here: https://www.typescriptlang.org/tsconfig#skipLibCheck

You can also check out the conversation in another thread on the usage of this property. https://stackoverflow.com/questions/52311779/usage-of-the-typescript-compiler-argument-skiplibcheck

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.