fuels-ts icon indicating copy to clipboard operation
fuels-ts copied to clipboard

SDK not compiling on user's projects

Open arboleya opened this issue 11 months ago • 8 comments

Repro

node -v &&
  mkdir temp-app && \
  cd temp-app && \
  pnpm init && \
  pnpm add fuels typescript && \
  echo 'import { Fuel } from "fuels"; console.log(Fuel.STORAGE_KEY);' > app.ts && \
  pnpm tsc app.ts

Error Digest

error TS1259: Module '"/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag
error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownArrayOrTuple'.
error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownRecord'.
error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Source>>>[number]' and 'UnknownArrayOrTuple'.
error TS2688: Cannot find type definition file for 'web'.
error TS2688: Cannot find type definition file for 'web'.
error TS4090: Conflicting definitions for 'node' found at '/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@types/node/index.d.ts' and '/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@types/node/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.

Full Error

Click to expand
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/abi-coder/dist/encoding/coders/v0/ByteCoder.d.ts(3,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/abi-coder/dist/encoding/coders/v0/EnumCoder.d.ts(11,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/abi-coder/dist/encoding/coders/v0/StdStringCoder.d.ts(3,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/abi-coder/dist/encoding/coders/v0/StringCoder.d.ts(3,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/abi-coder/dist/FunctionFragment.d.ts(5,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/account/dist/connectors/types/local-storage.d.ts(1,23): error TS2688: Cannot find type definition file for 'web'.
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/account/dist/providers/provider.d.ts(1,23): error TS2688: Cannot find type definition file for 'web'.
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/account/dist/providers/provider.d.ts(188,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/account/dist/wallet-manager/vaults/mnemonic-vault.d.ts(10,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/account/dist/wallet-manager/vaults/privatekey-vault.d.ts(9,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/account/dist/wallet-manager/wallet-manager.d.ts(15,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/math/dist/bn.d.ts(2,8): error TS1259: Module '"/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@types/bn.js/index"' can only be default-imported using the 'esModuleInterop' flag
node_modules/.pnpm/@[email protected][email protected]/node_modules/@fuel-ts/program/dist/instruction-set.d.ts(6,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/transactions/dist/coders/byte-array.d.ts(4,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/abi-coder.d.ts(21,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/coders/abstract-coder.d.ts(14,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/coders/abstract-coder.d.ts(96,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/coders/abstract-coder.d.ts(109,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/fragments.d.ts(109,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/interface.d.ts(171,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/abi/typed.d.ts(78,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/contract/wrappers.d.ts(55,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/contract/wrappers.d.ts(71,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/crypto/signature.d.ts(33,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/crypto/signing-key.d.ts(14,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/hash/typed-data.d.ts(50,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/abstract-provider.d.ts(253,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/abstract-signer.d.ts(51,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/ens-resolver.d.ts(90,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/network.d.ts(28,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/plugins-network.d.ts(130,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/plugins-network.d.ts(146,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-browser.d.ts(41,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-etherscan.d.ts(80,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-fallback.d.ts(84,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.d.ts(1,23): error TS4090: Conflicting definitions for 'node' found at '/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@types/node/index.d.ts' and '/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@types/node/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
  The file is in the program because:
    Type library referenced via 'node' from file '/temp-app/node_modules/.pnpm/@[email protected]/node_modules/@fuel-ts/math/dist/bn.d.ts' with packageId '@types/node/[email protected]'
    Type library referenced via 'node' from file '/temp-app/node_modules/.pnpm/[email protected]/node_modules/undici-types/formdata.d.ts' with packageId '@types/node/[email protected]'
    Type library referenced via 'node' from file '/temp-app/node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.d.ts' with packageId '@types/node/[email protected]'
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-ipcsocket.d.ts(12,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-jsonrpc.d.ts(212,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-jsonrpc.d.ts(326,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-jsonrpc.d.ts(344,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-socket.d.ts(21,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-socket.d.ts(71,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-socket.d.ts(88,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider-websocket.d.ts(31,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider.d.ts(269,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider.d.ts(514,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/provider.d.ts(687,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/providers/signer-noncemanager.d.ts(11,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/transaction/transaction.d.ts(90,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/utils/events.d.ts(58,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/utils/fetch.d.ts(45,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/utils/fetch.d.ts(66,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/utils/fetch.d.ts(294,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/utils/fixednumber.d.ts(63,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/wallet/base-wallet.d.ts(17,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/wallet/hdwallet.d.ts(27,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/wallet/wallet.d.ts(17,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/wordlists/wordlist-owl.d.ts(15,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/ethers/lib.commonjs/wordlists/wordlist-owla.d.ts(15,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(140,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownArrayOrTuple'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(140,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownRecord'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(140,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Source>>>[number]' and 'UnknownArrayOrTuple'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(166,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownArrayOrTuple'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(166,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownRecord'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(166,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Source>>>[number]' and 'UnknownArrayOrTuple'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(192,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownArrayOrTuple'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(192,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownRecord'.
node_modules/.pnpm/[email protected]/node_modules/type-fest/source/merge-deep.d.ts(192,5): error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Source>>>[number]' and 'UnknownArrayOrTuple'.

arboleya avatar Mar 20 '24 22:03 arboleya

this happens with 0.77, 0.76 and 0.72 node versions 20 and 18.19.1

great9 avatar Mar 20 '24 23:03 great9

also problems with type-fest import in fuels-ts

great9 avatar Mar 20 '24 23:03 great9

By running pnpm tsc app.ts typescript's default compiler options are used. This still emits the app.js file, but it prints out problems typescript finds in the dependencies - some due to excessive stack depth due to the recursive type generics are programmed, others due to a dependency using >ES2015 features while tsc's default is ES3, etc.

Long story short, running pnpm tsc app.ts --skipLibCheck stops the errors being printed out and the user will get app.js.

However, I'd highly suggest looking into using a tsconfig file and running pnpm tsc -p tsconfig.json. This one is a good starter.

nedsalk avatar Mar 21 '24 08:03 nedsalk

By running pnpm tsc app.ts typescript's default compiler options are used. This still emits the app.js file, but it prints out problems typescript finds in the dependencies - some due to excessive stack depth due to the recursive type generics are programmed, others due to a dependency using >ES2015 features while tsc's default is ES3, etc.

mine is set to es2022

great9 avatar Mar 21 '24 08:03 great9

@great9 can you share your tsconfig.json contents with us and the full error log that gets produced?

nedsalk avatar Mar 21 '24 09:03 nedsalk

@great9 can you share your tsconfig.json contents with us and the full error log that gets produced?

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Node 18",
  "target": "es2022",
  "compilerOptions": {
    "lib": [
      "es2022",
      "dom"
    ],
    "module": "commonjs",
    "moduleResolution": "Node",
    "target": "es2022",
    "esModuleInterop": true,
    "skipLibCheck": false,
    "forceConsistentCasingInFileNames": true,
    "outDir": "dist",
    "declaration": true,
    "strict": true,
    "noUnusedLocals": true
  },
  "include": [
    "src/**/*"
  ]
}

great9 avatar Mar 21 '24 15:03 great9

Thanks, can you set skipLibCheck to true and see if it fixes it?

nedsalk avatar Mar 21 '24 15:03 nedsalk

Thanks, can you set skipLibCheck to true and see if it fixes it?

I'm sure it will, but will the app work? Former version worked with skipLibCheck set to false...

great9 avatar Mar 21 '24 16:03 great9

The quick answer is it'll work because skipLibCheck is a stricter setting for compile-time checks and it doesn't affect the runtime. I'd have to do a deeper diver to understand which dependencies we (or you) introduced that's creating a conflict that skipLibCheck finds.

nedsalk avatar Mar 25 '24 13:03 nedsalk