Many times, TypeScript can infer the types of arguments you pass in a function call by looking at their definition. Consider the following example:
const promise = Promise.resolve(15);
f(promise);
In this case, TypeScript can infer the type of promise as Promise<number>. We can take advantage of this information to add type information to the first parameter of f. So given the following code as input:
Many times, TypeScript can infer the types of arguments you pass in a function call by looking at their definition. Consider the following example:
In this case, TypeScript can infer the type of
promise
asPromise<number>
. We can take advantage of this information to add type information to the first parameter off
. So given the following code as input:We should be able to discover the type of argument
a
correctly, and get the following result:This PR adds experimental support for this feature. At this time, the code is still work-in-progress and is not yet ready to be merged.