Andrey (azangru) wrote,

Typescript surprises me.

Say we have a function:

What will the type of the return value be? What if there is no colon in the provided string — then bar will be undefined. But typescript has the utmost confidence in the programmer, and is happy to infer that both foo and bar are strings:

This is dangerous! Here, we shall get an undefined is not a function:

Flow behaves the same, by the way.

  • Via Twitter

    Via a tweet, but I thought I'd get my own copy. A beautiful illustration of how a caption totally misrepresents what's been captured in the photo.…

  • (no subject)

    Here's an extract from Uncle Bob's book Clean Agile. Although he has fallen out of grace with the champions of social justice, the sentiment…

  • (no subject)

    Twelve thousand people pressed the button. Obviously most of them his followers, but still... interesting:

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.