PrismarineJS / mineflayer

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

Test typing to avoid typing PRs #2519

Open rom1504 opened 2 years ago

rom1504 commented 2 years ago
  1. in all modules we will have a large test-typing.ts that just call everything and create everything (it will not work but it will compile)
  2. we add tsc typings/test-typings in npm test of all modules
  3. in all PRs adding a new thing in API, they will have to add something in test-typing.ts

example https://github.com/PrismarineJS/node-minecraft-data/blob/master/package.json#L10 https://github.com/PrismarineJS/node-minecraft-data/blob/master/typings/test-typings.ts

EnderTheCoder commented 2 years ago

Hope this can work soon. I really want to use typescript to replace javascript in my project.

rom1504 commented 2 years ago

This will not change a single thing with support of typescript. You can already use mineflayer in your typescript project

EnderTheCoder commented 2 years ago

It's just the problem of autocomplete. I just solved it. When I tried to use mineflayer in the way of your example, vscode didn't give any suggestions.

2022-03-22 10-16-10 的屏幕截图

But if I code something like "import mineflayer from ‘mineflayer’", it worked.

2022-03-22 10-15-28 的屏幕截图

IceTank commented 2 years ago

But if I code something like "import mineflayer from ‘mineflayer’", it worked.

Yes because typescript dose not add types without import when using require. To get types with require you would need to do something like this import mineflayer = require('mineflayer').