Skip to content

Generics with 'extends' for return types cause type check failure. #13993

Description

@na-o-ys

TypeScript Version: 2.2.0

Code

interface I { attr: string }

type M = <T extends I>() => T
const v: M = () => ({})

v().attr

Expected behavior:

Type '() => {}' is not assignable to type 'M'. Type '{}' is not assignable to type 'I'.

Actual behavior:

The compilation is successful.

Activity

  1. zpdDG4gta8XKpMCd commented on Feb 10, 2017

    @zpdDG4gta8XKpMCd

    Ryan Cavanaugh (@RyanCavanaugh) is there any chance to fix assignability checks for generic and do it properly? not sure which issue tracks it (there are way to many)

  2. ahejlsberg commented on Aug 15, 2017

    @ahejlsberg
    Member

    Fixed by #16368.

  3. locked and limited conversation to collaborators on Jun 19, 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

    FixedA PR has been merged for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions