Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
hexc11266yJavaScript really encouraged bad practices, should use typescript to prevent these types of problems
-
@hexc we use flow. The function's return type was number. It was not returning a number and flow didn't catch that error. I'm pretty sure typescript wouldn't either, but I might be wrong.
-
@hexc flow works pretty much the same way.
As I said, the function's return type was set to number but the function was actually returning a string. -
Same issue with Python.
Getting "27" from reading a text file: int
Getting "27" from an internal variable: string.... Fuck off
Coworker: I give up! Please help me!
Me: What's up?
C: Take a look at this. I have this function here that gets the tab index and I'm passing it to the Tabs component over there. I'm logging the index and as you can see it's 3, but the Tabs component isn't working. However if I replace the function call with a 3 it works!
Coworker 2: While you were explaining all that, shellbug already thought about at least 3 reasons why that isn't working.
Me: **sighs** Of what type is the value that function is returning?
C: **stares at me for a few seconds** It's a number.
Me: Are you sure?
C: Well, it's returning 3.
Me: Please do a typeof.
It was string.
rant
debugging
javascript
string is not number
types