Flow: Weird error messages when adding object to number

Created on 31 Oct 2016  路  2Comments  路  Source: facebook/flow

https://flowtype.org/try/#0PQKgBAAgZgNg9gdzCYAoVBGMBqMBvAXwG4g

The weird part is that first two errors are pointing to the same 1 which is mentioned as number and string at the same time and it is also mentioned that I try to add it to itself

3: 1 + {};
   ^ number. This type cannot be added to
3: 1 + {};
   ^ string
3: 1 + {};
       ^ object literal. This type cannot be added to
3: 1 + {};
   ^ string
other bug

Most helpful comment

that's bizarre... it should just be

3: 1 + {};
       ^ object literal. This type cannot be added to
3: 1 + {};
   ^ number

I'll look into it. thanks!

All 2 comments

IMO the output above should look like

3: 1 + {};
   ^ string (coerced from number). This type cannot be added to
3: 1 + {};
       ^ object literal. This type cannot be added to
3: 1 + {};
   ^ string

or even better

3: 1 + {};
   ^ number. This type cannot be added to
3: 1 + {};
       ^ object literal. This type cannot be added to
3: 1 + {};
   ^ number

that's bizarre... it should just be

3: 1 + {};
       ^ object literal. This type cannot be added to
3: 1 + {};
   ^ number

I'll look into it. thanks!

Was this page helpful?
0 / 5 - 0 ratings