Skip to content

Generics aren't working as expected when using them with PartialΒ #43125

Closed
@ghost

Description

Bug Report

πŸ”Ž Search Terms

generic partial

πŸ•— Version & Regression Information

4.2.2

⏯ Playground Link

Playground Link

πŸ’» Code

type FunctionType<T> = {
  func(arg: Partial<T>): any;
};

type StringType = {
  str: string;
};

function example<T extends StringType>(ft: FunctionType<T>) {
  ft.func({ str: "" });
}

πŸ™ Actual behavior

The code doesn't compile because ft.func({ str: "" }) gives the following error

Argument of type '{ str: ""; }' is not assignable to parameter of type 'Partial<T>'.

πŸ™‚ Expected behavior

I would expect the code to compile

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