TypeError: Class extends value undefined is not a constructor or null

Hey, newbie here in both TypeScript and Sapphire, and I'm trying to build a command but I'm getting the error specified in the title, my code for the constructor is the following:
public constructor(context: CommandContext, options: Command.Options) {
super(context, {
description: 'Play a song',
preconditions: [ new VoiceChannelOnly() ],
options: [
{
name: 'play',
description: 'Play a song from YouTube',
type: 'STRING',
required: true
}
]
});
}
public constructor(context: CommandContext, options: Command.Options) {
super(context, {
description: 'Play a song',
preconditions: [ new VoiceChannelOnly() ],
options: [
{
name: 'play',
description: 'Play a song from YouTube',
type: 'STRING',
required: true
}
]
});
}
I know it isn't the best but I'm not sure what's wrong with this, any help?
Solution:
Write a proper tsconfig. By default with no target set it compiles to ES3 which doesn't support classes.
Jump to solution
9 Replies
Solution
Favna
Favna2y ago
Write a proper tsconfig. By default with no target set it compiles to ES3 which doesn't support classes.
Favna
Favna2y ago
extend @sapphire/ts-config and/or read up on tsconfig options.
kzts
kztsOP2y ago
Will setting the target in the compiler options to ES2021 fix it?
Favna
Favna2y ago
yes but again, you should read up on what everything in tsconfig does. You shouldnt set values you have no idea for what they do.
Favna
Favna2y ago
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
kzts
kztsOP2y ago
Alright, thank you Are there any example and opensource bots made with Sapphire?
Spinel
Spinel2y ago
Discord bots that use @sapphire/framework v4 - Official Bot Examples ᴱ ᴰ ᴶˢ - Dragonite ᴱ ᴰ Discord bots that use @sapphire/framework v3 - Archangel ᴱ ᴰ - Arima ᴱ - Nino ᴱ ᴰ - Operator ᴱ ᴬ ᴰ - Radon ᴱ ᴬ - Sapphire Application Commands Examples ᴱ - Spectera ᴬ Discord bots that use @sapphire/framework v2 - Materia ᴱ - RTByte ᴱ ᴬ - Skyra ᴬ ᴰ - YliasDiscordBot ᴬ : Uses ESM (if not specified then uses CJS) : Advanced bot (if not specified it is a simple bot, or not graded) : Uses Docker in production ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
Lioness100
Lioness1002y ago
@BHS.
Spinel
Spinel2y ago
Discord bots that use @sapphire/framework v4 - Official Bot Examples ᴱ ᴰ ᴶˢ - Dragonite ᴱ ᴰ Discord bots that use @sapphire/framework v3 - Archangel ᴱ ᴰ - Arima ᴱ - Nino ᴱ ᴰ - Operator ᴱ ᴬ ᴰ - Radon ᴱ ᴬ - Sapphire Application Commands Examples ᴱ - Spectera ᴬ Discord bots that use @sapphire/framework v2 - Materia ᴱ - RTByte ᴱ ᴬ - Skyra ᴬ ᴰ - YliasDiscordBot ᴬ : Uses ESM (if not specified then uses CJS) : Advanced bot (if not specified it is a simple bot, or not graded) : Uses Docker in production ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
Want results from more Discord servers?
Add your server