Annotating Function Parameters with Flow

Flow has been a great tool at work, but it’s not without it’s quirks. After scouring their documentation, I figured out a way to annotate function function parameters (what a tongue twister):

function foo(bar: (baz: boolean) => string) {
    const text = baz(); // Flow knows text is a string now!

Super handy trick that can give you some extra type checking magic later in your project.

Join the newsletter

Want to impress your coworkers? Subscribe to get a weekly JavaScript tip on Thursdays!

I will never send you spam. Unsubscribe at any time.

Powered by WordPress. Designed by WooThemes