PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.76k stars 872 forks source link

Bug with imports in TypeScript (ECMAscript) #3032

Closed ghost closed 1 year ago

ghost commented 1 year ago

Versions

Detailed description of a problem

A clear and concise description of what the problem is, with as much context as possible. What are you building? What problem are you trying to solve?

../node_modules/mineflayer/index.d.ts:11:10 - error TS2305: Module '"prismarine-registry"' has no exported member 'Registry'.

11 import { Registry } from 'prismarine-registry'


../node_modules/mineflayer/index.d.ts:11:26 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

11 import { Registry } from 'prismarine-registry'

What did you try yet?

Did you try any method from the API? Did you try any example? Any error from those?

not well versed in typescript, not sure how to try

Your current code


simple mineflayer bot, connects to hypixel and leaves

Expected behavior

A clear and concise description of what you expected to happen. connects to hypixel, no import errors

Additional context

Add any other context about the problem here.

extremeheat commented 1 year ago

Please search through all the issues before making a new one, dupe of https://github.com/PrismarineJS/mineflayer/issues/2862

ghost commented 1 year ago

Following the suggested steps, it now returns the error

../node_modules/mineflayer/index.d.ts:11:9 - error TS1259: Module '"C:/Users/z/Downloads/adbot/adbot/node_modules/prismarine-registry/index"' can only be default-imported using the 'esModuleInterop' flag

11 import Registry from 'prismarine-registry'


  ../node_modules/prismarine-registry/index.d.ts:14:1
    14 export = loader
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

../node_modules/prismarine-biome/index.d.ts:1:8 - error TS1259: Module '"C:/Users/z/Downloads/adbot/adbot/node_modules/prismarine-registry/index"' can only be default-imported using the 'esModuleInterop' flag

1 import Registry from 'prismarine-registry'


  ../node_modules/prismarine-registry/index.d.ts:14:1
    14 export = loader
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

../node_modules/prismarine-block/index.d.ts:5:8 - error TS1259: Module '"C:/Users/z/Downloads/adbot/adbot/node_modules/prismarine-registry/index"' can only be default-imported using the 'esModuleInterop' flag

5 import Registry from 'prismarine-registry';


  ../node_modules/prismarine-registry/index.d.ts:14:1
    14 export = loader
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

Also, the error is coming from a different package and it is also a different error, as shown here. 207449615-3b8d1efe-4410-4295-b9ce-4562d8140719

before opening this issue, I did search through the issues, but a solution was not found

Requesting for this issue to be reopened @extremeheat

ghost commented 1 year ago

I do think that the error is not in mineflayer, but in prismarine registery. Asking for confirmation

../node_modules/prismarine-registry/index.d.ts:14:1 14 export = loader


    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
extremeheat commented 1 year ago

Requesting for this issue to be reopened

the other one is still open

ghost commented 1 year ago

Requesting for this issue to be reopened

the other one is still open

@extremeheat do think think it's mineflayer or the other package thats bugging out

dxxxxy commented 1 year ago

As these errors still exist, I've made an alternate package @dxxxxy/mineflayer (https://github.com/DxxxxY/mineflayer) which uses my three other alternate fixed packages related to the Registry export type mishap.

u9g commented 1 year ago

As these errors still exist, I've made an alternate package @dxxxxy/mineflayer (https://github.com/DxxxxY/mineflayer) which uses my three other alternate fixed packages related to the Registry export type mishap.

Would you mind pr'ing these?

dxxxxy commented 1 year ago

As these errors still exist, I've made an alternate package @dxxxxy/mineflayer (https://github.com/DxxxxY/mineflayer) which uses my three other alternate fixed packages related to the Registry export type mishap.

Would you mind pr'ing these?

I was looking around before this and some of these changes are actually already implemented on the latest branches. They're simply unpublished or unused by mineflayer.

dxxxxy commented 1 year ago

Also, I had to go back to the published versions of the packages because the fix wouldn't work on the latest commits. (so i can't really PR)