Skip to content

Cannot define a Partial<T> for a constrained T extends Base specifying only members of Base #12799

Closed
@pzavolinsky

Description

@pzavolinsky

TypeScript Version: 2.1.4

Code

interface Base {
  page: number
}

function test<T extends Base>() {
    const firstPage:Partial<T> = { page: 1 };
}

Also reproducible here.

Expected behavior:
firstPage should be accepted as a valid partial instance of T.

Actual behavior:

error TS2322: Type '{ page: 1; }' is not assignable to type 'Partial<T>'.

Also, the error is not very helpful explaining why the type is not assignable.

Activity

pzavolinsky

pzavolinsky commented on Dec 9, 2016

@pzavolinsky
Author

Related to #12731.

I believe this should be considered a bug rather than a suggestion (as the issue above).

added
Working as IntendedThe behavior described is the intended behavior; this is not a bug
and removed
Working as IntendedThe behavior described is the intended behavior; this is not a bug
on Dec 13, 2016
mhegazy

mhegazy commented on Oct 31, 2017

@mhegazy
Contributor

Duplicate of #16356 and #19388

added
DuplicateAn existing issue was already created
and removed
Needs InvestigationThis issue needs a team member to investigate its status.
on Oct 31, 2017
mhegazy

mhegazy commented on Oct 31, 2017

@mhegazy
Contributor

Use Partial<Base> instead.

typescript-bot

typescript-bot commented on Nov 16, 2017

@typescript-bot
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

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

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @pzavolinsky@RyanCavanaugh@mhegazy@typescript-bot

        Issue actions

          Cannot define a Partial<T> for a constrained T extends Base specifying only members of Base · Issue #12799 · microsoft/TypeScript