Hacker News new | past | comments | ask | show | jobs | submit login

I appreciate the effort you’ve both put in to concrete examples. I think yours gets to a point that I haven’t often seen stated. You’ve named your interface Person, but perhaps even Emailable could serve the purpose. The problem is that you had to name it. Naming well is hard, and I believe strong type systems often create a need for more names. It’s a cost I don’t often see considered in the tradeoff.



Instead of giving the interface an explicit name, I think you could instead use something like this:

    function getEmails(group: Array<{email: string}>) {
        return group.map((p) => p.email)
    }
which leaves the function more open ended than relying on an explicitly named interface that other types then have to inherit from.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: