I was reading the type inference documentation for TypeScript, which seem to target (quite reasonably) cases where TypeScript can surely identify types. I am curious about whether the compiler can be used to access generally inferred type information about JavaScript code. For example, is there a compiler API that would read code such as:
function f(x) {
x.q = g(x.p);
return x.h();
}
and output information of the form: "x has a type that, at least, has a readable property called p, a writable property called q, and a callable property/method called h"? This is intended at a toy example, and if such an API exists, I am curious about how general it is (i.e., how precise it is for more complex cases).