ts-node giving issues with Sapphire (edit: DO NOT USE TS-NODE)

Solution:
TL;DR: Do not use ts-node, use tsc-watch instead. We very strongly discourage using ts-node because it was never meant to be used for bots. ts-node is designed for REPL purposes. That's short for Read Eval Print Loop....
Jump to solution
4 Replies
Hoang Hai Anh
Hoang Hai Anh16mo ago
idk why
Favna
Favna16mo ago
ts-node does not automatically pick up .d.ts files
Solution
Spinel
Spinel16mo ago
TL;DR: Do not use ts-node, use tsc-watch instead. We very strongly discourage using ts-node because it was never meant to be used for bots. ts-node is designed for REPL purposes. That's short for Read Eval Print Loop. Which means to read some code, dump it in an eval() statement, print the result, and loop. A discord bot is not that. A Discord bot sets up a permanent websocket connection to the discord server and connects to the rest gateway. There is read yes, but no eval, no print, and no loop. So what should you use instead? The most ideal way is to just use the watch flag of tsc (tsc --watch) and run node dist/index.js to run your bot, then cancel that process and restart it when you have changes that require restarting. You would open 2 terminal tabs, 1 in which you run tsc --watch and another in which you run the bot. This is in particular the most ideal way, because Discord has a limit to the amount of times you can login with your bot, or register commands, per day. Constantly logging in over and over again due to an auto-restarting process will get you close to that limit very quickly and once you exceed it, your development will be halted entirely for the current day. However, this can be quite tedious so a great package to use instead is tsc-watch.
Favna
Favna16mo ago
should also note you have to add the augments within the boundaries set by your tsconfig includes, i.e. if your includes is "includes": ["src"] then augments should be at least src/augments.d.ts