Skip to content

Casting U|T to U is newly an error in nightly (4.8.0-dev.20220609)Β #49457

Description

@frigus02

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

functionf<U,T,XextendsU|T>(x: X){const_: U=xasU;// ^^^^^^// 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions