export interface MusicOptions {
requiresVc: boolean;
requiresPlaying: boolean;
requiresDjRole: boolean;
}
interface Args {
interaction: ChatInputCommandInteraction
client: ExtClient
player: ExtPlayer
}
type Command = {
data: Omit<SlashCommandBuilder, 'addSubcommandGroup' | 'addSubcommand'> | SlashCommandSubcommandsOnlyBuilder;
musicCommand?: MusicOptions
callback: (_: Args) => any
} | {
data: Omit<SlashCommandBuilder, 'addSubcommandGroup' | 'addSubcommand'> | SlashCommandSubcommandsOnlyBuilder;
musicCommand?: undefined,
callback: (_: Omit<Args, 'player'>) => any
}```
For some reason when I add the `Omit<Args, 'player'>` part to the 2nd part of the union type it turns all other arguments including player into any for the first part of the union (the one where musicCommand is MusicOptions)
#Problem with typescript interfaces
8 messages · Page 1 of 1 (latest)
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
✅Marked as resolved by OP
Well, why is musicCommand optional in the first union member? In that case both union members would apply if there‘s no musicCommand in it and thus both callback types would apply to the function
oh I must've forgotten to remove the optional thing from it
lemme try
yeah that's not it
I removed the optional operator from both unions and that didn't change anything unfortunately
How do you make sure you access the first union member and not the second? As in where do you have the issue with those being any?