Skip to content

{ [K in keyof T]: T[K] } like type not work with generic type #33529

Closed
@vipcxj

Description

@vipcxj

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms:

Code

function test<T extends { a: string, b: string }>(obj: T) {
   const test: Partial<T> = { a: 'a', b: 'b' }; // TS2322 type '{ a: string, b: string }' is not assignable to type 'Partial<T>'.
}

Expected behavior:
no error

Actual behavior:
TS2322 error

Playground Link:

Related Issues:
#33524

Metadata

Metadata

Assignees

No one assigned

    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