Skip to content

Superclass type argument inferred as unknown when it's only used as a method parameter type constraintΒ #63737

Description

@aweebit

πŸ”Ž Search Terms

"class" "extends" "constraint" "infer" "unknown"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "infer"

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYGwhgzhAECCA8AVAfNA3gWAFDWgWwFMAXACwHsATeAVWgIA8iCA7CmFACjACcBzALmjUAlOgC+2CVmyhIMAEJJUDJqxgIU47NiIBPAA4FoAYTLduBYEWgBeaIoBGZMiAJhmyxizb34AS2YAMwJuaE0AfjDoQWYCADcQgG5oAHoU6CcXN2YdAyMASWZgMwsrW19M13dPVR8EAODQiKiY+KTU9IBXZgBrZjIAdxysIA

πŸ’» Code

class A<T> {
  method<U extends T>(arg: U) {}
}

class B<T> extends A<T> {}

type Correct = B<boolean> extends B<infer T> ? T : never; // boolean
type Incorrect = B<boolean> extends A<infer T> ? T : never; // unknown

πŸ™ Actual behavior

Incorrect is evaluated to unknown

πŸ™‚ Expected behavior

Incorrect is evaluated to boolean

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions