Skip to content

Downcast leads to compiler error TS2352 #17338

Closed

Description

Compiling

interface Base { v2: string; }
interface A extends Base { v1: number; }
interface B extends Base { v3: object; }
const x: A = { v1: 5, v2: "I'm a c", v3: { hans: 'franz' } } as A;
const y: B = x as B;

with TypeScript 2.4.2 leads to

error TS2352: Type 'A' cannot be converted to type 'B'.
  Property 'v3' is missing in type 'A'.

I expect that this code compiles!

Activity

  1. RyanCavanaugh commented on Jul 21, 2017

    @RyanCavanaugh
    Member

    That is not a downcast.

    Duplicate of #7531, #16995, etc

  2. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions