Closed kevinlul closed 1 year ago
More minimal repro case: TS playground
For the bot
// Simplified from discord.js https://github.com/discordjs/discord.js licence Apache 2.0
interface ClientEvents {
warn: [message: string];
shardDisconnect: [closeEvent: CloseEvent, shardId: number];
}
declare class Client {
public on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => void): void;
}
// Demonstrative code
const bot = new Client();
// two declared params
bot.on("shardDisconnect", (event, shard) => console.log(`Shard ${shard} disconnected (${event.code},${event.wasClean}): ${event.reason}`));
// single declared param
bot.on("shardDisconnect", event => console.log(`${event.code} ${event.wasClean} ${event.reason}`))
The change between origin/release-4.5 and origin/release-4.8 occurred at fd601ddf20af2a69e56d69fe418d0f80905ce66b.
Bug Report
🔎 Search Terms
"distributed conditional types"
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The indicated line fails to compile in TypeScript 4.7, 4.8, and 4.9, when it had compiled in TypeScript 4.6. Making the log statement not a return statement with curly braces, explictly typing
event: CloseEvent
, or dropping the second argument to the lambda function fixes the issue.🙂 Expected behavior
All statements should compile.