MineDojo/Voyager

npx tsc error TS2345

Vance0124 opened this issue · 5 comments

When I run the command:

npx tsc

It runs wrong with the errors:

src/BlockVeins.ts:25:32 - error TS2345: Argument of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/mineflayer/node_modules/prismarine-block/index").Block' is not assignable to parameter of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/prismarine-block/index").Block'.
  The types returned by 'getProperties()' are incompatible between these types.
    Type '{ [key: string]: string | number | boolean; }' is not assignable to type '{ [key: string]: string | number; }'.
      'string' index signatures are incompatible.
        Type 'string | number | boolean' is not assignable to type 'string | number'.
          Type 'boolean' is not assignable to type 'string | number'.

25           if (targets.includes(neighbor)) continue
                                  ~~~~~~~~

src/BlockVeins.ts:26:29 - error TS2345: Argument of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/mineflayer/node_modules/prismarine-block/index").Block' is not assignable to parameter of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/prismarine-block/index").Block'.

26           if (open.includes(neighbor)) continue
                               ~~~~~~~~

src/BlockVeins.ts:28:21 - error TS2345: Argument of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/mineflayer/node_modules/prismarine-block/index").Block' is not assignable to parameter of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/prismarine-block/index").Block'.

28           open.push(neighbor)
                       ~~~~~~~~

src/CollectBlock.ts:209:23 - error TS2345: Argument of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/prismarine-block/index").Block' is not assignable to parameter of type 'import("E:/PythonProject/server/Voyager/voyager/env/mineflayer/node_modules/mineflayer/node_modules/prismarine-block/index").Block'.
  Type 'Block' is missing the following properties from type 'Block': setSignText, getSignText

209         await bot.dig(block);
                          ~~~~~


Found 4 errors in 2 files.

Errors  Files
     3  src/BlockVeins.ts:25
     1  src/CollectBlock.ts:209

How can I fix it? Please tell me, thanks.

Hi, did you fix this problem? I encountered the same issue.

I'm having this issue, too.

This may be caused by a different version of node js. I personally used these versions to run all experiments:

$ node -v
v16.13.0
$ npm -v
9.6.2
$ npx tsc -v
Version 5.0.2

Hi, did you fix this problem? I encountered the same issue.

@Foxy6670 @Foxy6670 This is due to a version issue with prismarine-block (try npm show prismarine-block, It will display 1.17.1 or some other version but should be 1.16.3 ). For me, I switched the path location to the voyager/env/mineflayer/node_modules/mineflayer/node_modules/ and voyager/env/mineflayer/node_modules/, and used the following commands:
npm uninstall prismarine-block
npm install prismarine-block@1.16.3

The preceding commands need to be executed on both paths.

Alternatively, cd into mineflayer-collectblock and run npm install.

Here are better steps derived from the README.

cd voyager/env/mineflayer/mineflayer-collectblock
npm install
npx tsc
cd ..
npm install