Open robfig opened 5 years ago
Consider the following:
function a() {
var arr = [ { a: 1, b: 2 }, [ 3, 4, 5 ] ];
return arr[Math.floor(Math.random() * 2)];
}
Without a strict typing system, autocompletion of chaining is not reliable.
Interestingly, chromium tries to guess, it looks like based on the last invocation of the function:
Yes, that's true, but I think in most cases the type returned is stable, especially without changing the arguments to the function. At any rate, it would do the right thing much more often than the current behavior, which never does the right thing in that scenario?
I noticed that chained expressions do not work with the autocompleter. I was curious if there was any thought on how to support that?
For example, assuming
a()
returns an object, I would wanta().<TAB>
to show me that object's properties, but currently the autocompleter shows me globals instead. Looking at the code, I think it would work iflastExpressionRegex
changed to select the entire expression. That would result in invoking the function multiple times, but that could be ok..cc @deoxxa