question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Argument of type '"stateChange"' is not assignable to parameter of type 'VoiceConnectionStatus.Signalling'

See original GitHub issue

Which package is this bug report for?

voice

Issue description

  1. Copy this repo: https://github.com/kaaaxcreators/Discord-MusicBot/tree/develop
  2. Then try to build it
  3. Typescript Error: Argument of type '"stateChange"' is not assignable to parameter of type 'VoiceConnectionStatus.Signalling' here: https://github.com/kaaaxcreators/Discord-MusicBot/blob/f86381c6988348ca32d55ff1e383caf179d2e387/src/util/Music.ts#L61 and here https://github.com/kaaaxcreators/Discord-MusicBot/blob/f86381c6988348ca32d55ff1e383caf179d2e387/src/util/Music.ts#L122

Code sample

https://github.com/kaaaxcreators/Discord-MusicBot/blob/develop/src/util/Music.ts
(Its the discord/voice Music Bot example fitted to my needs)

Package version

0.8.0

Node.js version

16.13.2, 4.6.2

Operating system

Windows 10 21H1

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

Channel

Which gateway intents are you subscribing to?

Guilds, GuildEmojisAndStickers, GuildVoiceStates, GuildMessages, GuildMessageReactions, DirectMessages, DirectMessageReactions

I have tested this issue on a development release

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
Crawroncommented, Mar 24, 2022

Happens to me as well. Issue seems to be on the second half of AudioPlayerEvents and VoiceConnectionEvents.

} & {
    [status in VoiceConnectionStatus]: (oldState: VoiceConnectionState, newState: VoiceConnectionState & {
        status: status;
    }) => Awaited<void>;
};

Changing the line status: status; on both AudioPlayerEvents and VoiceConnectionEvents to be a conditional type like below fixes the issue, as far as I can tell.

} & {
    [status in VoiceConnectionStatus]: (oldState: VoiceConnectionState, newState: VoiceConnectionState & {
        status: status extends VoiceConnectionStatus ? status : VoiceConnectionStatus;
    }) => Awaited<void>;
};

Should I PR this change?

1reaction
Zhincorecommented, Mar 5, 2022

I have similar issue Argument of type '"stateChange"' is not assignable to parameter of type 'AudioPlayerStatus.Idle'.

The following snippet has the problem:

player.on("stateChange", (oldState, state) => {
  /*...*/
});

But this one doesn’t throw any error:

player.on("stateChange", () => {
  /*...*/
});

The workaround is following:

player.on<"stateChange">("stateChange", (oldState, newState) => {
  /*...*/
});

I assume the parameters somehow infer different type than “stateChange”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument of type [type] is not assignable to parameter of type ...
Think that this line hints to the main issue: Type 'firebase.firestore.CollectionReference' is not assignable to type 'FirebaseFirestore.
Read more >
Class AudioPlayer - discordjs/voice
Will throw if attempting to play an audio resource that has already ended, or is being played by another player. Type parameters. T....
Read more >
Voice Connections | discord.js Guide
Voice Connections. Voice connections represent connections to voice channels in a guild. You can only connect to one voice channel in a ...
Read more >
Argument of type 'string' is not assignable to parameter of type
I'm new to Typescript and trying to do a project with it to get better, but I've been unable to solve this issue...
Read more >
Argument of type NextHandleFunction is not assignable
How to fix the issue for the latest node express regarding with Argument of type NextHandleFunction is not assignable to parameter of type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found