Skip to content

Type parameters as constraints dosen't work for methods #7079

Closed
@hayeah

Description

@hayeah

PR #5949 implements F-bounded polymorphism. It doesn't seem to be working correctly for methods.

interface Table<T> {
  // For this method `T` is apparently a brand new type parameter.
  insert<T extends U, U>(obj: U): T;
  // insert(obj: any)
}

interface Foo {
  a: string;
  b: string;
}

let Foos: Table<Foo>;

// `foo1`'s type is inferred to be {a: 1}
let foo1 = Foos.insert({a: 1}) // => ;

// Should produce error
let foo2 = Foos.insert({c: 1});

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions