Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This[1] typechecks in Flow but not in TypeScript:

    /* @flow */

    interface HasIdentityFunction {
      id<A>(a: A): A
    }

    class Example implements HasIdentityFunction {
     id<A>(a: A): number {
       return 42;
     }
    }

    var x: string = (new Example(): HasIdentityFunction).id("hello")
[1] https://twitter.com/puffnfresh/status/1077072700609159168


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: