Skip to content

The spec doesn't describe the newest cast semantics #12419

Closed

Description

When casting from a type A to a type B, the spec says that either A is assignable to B, or B is assignable to A. But the playground allows something more general: in some cases, as long as A and B have a common subtype, it doesn’t warn. The next example is valid.

function f(x: number | string) {
    return <number | boolean>(x);
}

The playground uses the comparable relation. The spec should be updated to include it.

Activity

  1. added
    SpecIssues related to the TypeScript language specification
    BugA bug in TypeScript
    and removed on Nov 21, 2016
  2. RyanCavanaugh commented on Jul 20, 2020

    @RyanCavanaugh
    Member

    The spec is now an "archived" artifact and we won't be tracking defects against it anymore.

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

Metadata

Metadata

Labels

SpecIssues related to the TypeScript language specification

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions