-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Has ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Milestone
Description
Bug Report
🔎 Search Terms
intersection assignability omit compatability
🕗 Version & Regression Information
- This changed between versions 3.8.3 and 3.9.7
⏯ Playground Link
Playground link with relevant code
💻 Code
type APIApplicationCommandSubcommandGroupOption = {
options?: APIApplicationCommandSubcommandOption[];
}
type CommandSubcommandGroupOption = Omit<APIApplicationCommandSubcommandGroupOption, 'options'> & { // <-- so is this one
options?: CommandSubcommandOption[]
}
type CommandSubcommandOption = { otherProps: unknown } & { // <-- this intersection is apparently critical
options?: unknown[]
}
interface APIApplicationCommandSubcommandOption {
options?: { foo: string }[];
otherProps: unknown;
}
function transformSubcommandGroupOption1(option: CommandSubcommandGroupOption): APIApplicationCommandSubcommandGroupOption {
return option; // no error, but there _should_ be an error here.
}
function transformSubcommandGroupOption2(option: CommandSubcommandGroupOption): APIApplicationCommandSubcommandGroupOption {
return { ...option }; // error in 3.9.7
}
🙁 Actual behavior
The return option
does not produce an error and the return { ...option }
does produce an error.
🙂 Expected behavior
Both return
s should behave the same. Ideally, both should produce an error because CommandSubcommandGroupOption
is incompatible with APIApplicationCommandSubcommandGroupOption
.
From help thread on Discord: https://discord.com/channels/508357248330760243/964236133330460772
Metadata
Metadata
Assignees
Labels
Has ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.