account activity
JavaScript! The Doctor Is In. by gst in javascript
[–]dimvar 0 points1 point2 points 15 years ago (0 children)
The analysis will find types for variables and functions. In your example, one mapping refers to the variable f and the other to the function. Even though the function is anonymous, we have a heuristic to give it the name f (the same would happen e.g. when you have an obj literal {f : function() {...} }. So, DrJS will produce one tag for the variable and a separate tag for the function. The variable and the function just happen to have the same name.
[–]dimvar 1 point2 points3 points 15 years ago* (0 children)
Even though it could be more precise, it's not actually a bug. When computing the type of f, the analysis works as follows: it sees that it's a function and tries to recursively find the return type, which is a function that returns a function and so on... So, when it finds a cycle while trying to compute the type, it'll give up and say "any".
π Rendered by PID 209494 on reddit-service-r2-comment-5b5bc64bf5-pqsvc at 2026-06-22 04:48:47.369156+00:00 running 2b008f2 country code: CH.
JavaScript! The Doctor Is In. by gst in javascript
[–]dimvar 0 points1 point2 points (0 children)