owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!
https://owencalvin.github.io/discord.ts/
325 stars 40 forks source link

Fixed issue: Class with commands no longer needs to be the first export #46

Open charged-ion opened 3 years ago

charged-ion commented 3 years ago

If a user creates a file containing commands that is being imported through @Discord import, the very first export of the file had to be the class containing all of the commands. If the first export was something else, in example a string, a run time error will occur and the process will exit. The error returned is "Uncaught TypeError: classType is not a constructor".

This fix will allow users to be able to export constant values regardless of the location of the file without affecting the intended use of the class containing all of the commands.

Adondriel commented 3 years ago

what node version does the new p?.prototype?.constructor syntax require?

charged-ion commented 3 years ago

what node version does the new p?.prototype?.constructor syntax require?

It's not the node version, but rather Typescript version 3.7.

Context: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining