-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Bug Report
π Search Terms
TS2352, sufficiently overlaps
π Version & Regression Information
- This changed between versions 4.7.2 and v4.8.0-dev.20220609
β― Playground Link
Playground link (4.7.2) with relevant code (no error)
Playground link (nightly) with relevant code showing the error
π» Code
function f<U, T, X extends U|T>(x: X) {
const _: U = x as U;
// ^^^^^^
// Conversion of type 'X' to type 'U' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
// 'U' could be instantiated with an arbitrary type which could be unrelated to 'X'.(2352)
}
π Actual behavior
This is an error in nightly (4.8.0) but was fine in 4.7.2.
π Expected behavior
The new error doesn't feel helpful to me. I expect assigning U|T
to U
to be an error. But the explicit cast feels enough to me because U|T
seem related to U
. I don't feel like casting through unknown
should be necessary.
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug