Flow: Flow doesn't error for tuple missing values

Created on 9 Aug 2016  路  2Comments  路  Source: facebook/flow

I expected that this would be flagged by Flow, but it isn't. Even passing an empty array goes unnoticed by Flow. The documentation mentions that tuples are allowed to be longer than they're typed to be, but I don't think they should be allowed to be shorter than they're typed (unless the missing types are nullable).

/* @flow */

function foo(a: [Object, Object]) {}

foo([ {} ]);
$ flow version
Flow, a static type checker for JavaScript, version 0.30.0
$ flow
No errors!
bug

Most helpful comment

@gcanti Yup, tuples are pretty broken. Their implementation is pretty optimistic right now, if you do the correct operations you get the expected results (more precise than arrays), but they're not robust enough against incorrect operations. This has been on our radars for a while. Assigning myself and @samwgoldman.

All 2 comments

Related:

Tuples are almost unusable at the moment, I'm forced to use object types because they are safer

@gcanti Yup, tuples are pretty broken. Their implementation is pretty optimistic right now, if you do the correct operations you get the expected results (more precise than arrays), but they're not robust enough against incorrect operations. This has been on our radars for a while. Assigning myself and @samwgoldman.

Was this page helpful?
0 / 5 - 0 ratings