Flow: Non-verbose error: Missing type annotation for S.

Created on 19 Apr 2018  Â·  7Comments  Â·  Source: facebook/flow

when calling concat on a non-typed variable I got the below error

Missing type annotation for S.

     88│         this.sessions = this.sessions.concat(dataToSend);

It was mostly guesswork to find out what that means. Is it possible to make this error more verbose? Or is this actually an error of flow-typed or so?

All 7 comments

hmm, could you provide a bit more info on how to repro this? Is it reproducible on flow.org/try?

further investigation and it seems related to exporting results of array methods?, example here:

https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVA3AhgJzADzAF4wBtARgBoAmAXQG5VhgwcBTAWzgzbDfwAOcHABcwWAHYATPjhzCwAczgS2AfjCp+Q0WGx4AnsQIA6AMYqzWEQApSAZloBKRkxbsuPPoOFjJMtjkFZVUNNzAoAFcJMxEASxVxOSwDADE4mBFAmy0fXSiY+MTcHBT0zMCwGxKALjAAZxEcOIlFUlpKMARhKTrG5tanMABvME0x9hFInAkknBMoDKycG14iAD4+MABCIhJunCkXVABfIA

Duplicates #6151 ?

Yes! Thanks @brookemitchell for reproducing. For me it happened with concat but was not able to reproduce

@apsavin might be related but I wouldn't say duplicate.

I'd agree it's a duplicate of https://github.com/facebook/flow/issues/6151 , error is fixed by typing the exports return type.

However the error isn't very descriptive and I'm a little surprised it's necessary with exports when most return types can be inferred?

Fixed example:
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVA3AhgJzADzAF4wBtARgBoAmAXQG51hgwoBLfAUwBMwAjAJ5gALgIAObAHYBzMAIDkAZxHjOYVJ3xi4OYWGx4hALjCSArgFs+nHKVrECAOgDGcSc6zCAFKQDMtAEpGVGZWDh5+IVEJGTAcTmEzHEkVMTUNLR09KDN3YTY3MFwcLAEAMTYYYRswL2KTRWEcKWk7SjAEHW4GppaAnuaZOzAAbzB1cfjE5KKcHEd2KpsvNSIAPjA1AEIiEk6cbiDUAF8gA

Closing in favor of #6151. Not inferring types at module boundaries is an optimization: it allows flow to check files in parallel without going down deep inference rabbit holes.

That's pretty cool. Hopefully with nicer error message in the future

Was this page helpful?
0 / 5 - 0 ratings