-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Intersection causes incorrect type compatability #48720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Working out some bot kinks π 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
} |
π Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @webstrand β Failed: -
Historical Information
|
π Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript. β Failed: -
Historical Information
|
@typescript-bot bisect good v3.8.3 bad v3.9.7 |
The change between v3.8.3 and v3.9.7 occurred at b8baf48. |
Bug Report
π Search Terms
intersection assignability omit compatability
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The
return option
does not produce an error and thereturn { ...option }
does produce an error.π Expected behavior
Both
return
s should behave the same. Ideally, both should produce an error becauseCommandSubcommandGroupOption
is incompatible withAPIApplicationCommandSubcommandGroupOption
.From help thread on Discord: https://discord.com/channels/508357248330760243/964236133330460772
The text was updated successfully, but these errors were encountered: