Broken TypeScript command (from lack of knowledge of TS)
I'm attempting to create a command following the Sapphire wiki, but it seems that I can't get the command to work at all.
Note: I am very new to Typescript, I am not familiar with the syntax or the proper form to do stuff, please be gentle
This is the command I created, the .js version worked, but when i moved it over to TypeScript it just stopped working entirely.
36 Replies
Please share your full package.json, tsconfig.json and file/folder tree
What isn't working? Do you have a stack trace/error? Was it a build error?
The .js command is registering correctly and the bot is responding, the ts one is not showing any errors, no build errors and the bot is not reacting at all either
probably my tsconfig is the issue:
Like I said I'm new to it, so I apologize if this is just lack of knowledge
Haha is that my tsconfig
Yeah I figured why not copy the person that knows way more than me
lol
From the screenshot it looks like the JSON files are in the
src/
folder? Is that correct?yes
oh wait no
no the package and tsconfig are not in src
Is there a
commands/account.js
file in the dist folder?yes
I believe so
one moment, I'm in a game I'll screenshot when I get back
I can still chat though
you need yo compile your
account.ts
to JS
then change main
to dist/index.js
and rewrite all your src files from TS to JS
the ncompile
then run the bot againoh wait
is it because i did
main/index.js not dist/
im sad ok
also that tsconfig is invalid
Yeah most of those options should be under compilerOptions
it should be like this
it didnt throw errors when compiling
which is weird
okay thanks
A lot of them are also already enabled in the config you're extending iirc
ill mess around with it
this seems to just be a lack of knowledge thing
thank you
Lioness idk your config but there is a good chance you need to update it btw if you didnt already, for TS 5.2
GitHub
Update the tsconfig to better support TypeScript 5.2 by favna · Pul...
Warning
needs rebase & merge to ensure that the breaking change doesn't show up for the other packages
As TS 5.2 is really pushing for separating CJS and ESM entirely I have decided to com...
I'll look into it
TL;DR
node16
for both module
and moduleResolution
and make verbatimModuleSyntax
opt-inBut also @Baylem it's not in package.json so I'm not sure if typescript is even reading the extended config
Solution
My advice Baylem, use @sapphire/cli to generate a bot
then you'll have a good setup to start from
(just give it like an hour so we can roll out updates like this PR)
okay
Damn diss my config like that 🙄
I mean it's not just that. It's also the main property, package.json, folder setup, etc
Oh so it's not just that
Wow hide your disdain for me next time
lmao
now now ladies
you're both beautiful
error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node16'.
after using CLI, I'm troubleshooting and trying things. I tried adding the Compiler options above but I'm gettign this issue:
https://discord.com/channels/737141877803057244/1145844807017693295
I tried manually setting those to Node16 as stated here - and I get a top level export error, as stated above
A top-level  export modifier cannot be used on value declarations in a CommonJS module when  verbatimModuleSyntax is enabled.
Either write a full ESM bot or disable verbatimModuleSyntax
I used Sapphire CLI to generate the bot. I have 0 code written by me, so the templates arent ESM till the next update/release? @Favna
so adding
verbatimModuleSyntax: false
to my compiler options should work?
ah ok nvm it was a TS version mismatch as posted in the other thread@Baylem update has been released, see #Announcements