You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When dealing with large JavaScript codebases, it would be convenient if TypeScript could infer the type of function parameters from their usage in the body.
As a short example:
functioninferenceParam(param){letx=param*3;// param is inferred to be a number as well as x
...
letstr="Value of param : "+param;// Here param is implicitly casted to a stringconsole.log(param.wrongProperty);// Error since param is a number and no wrongProperty exists on Number.}
TypeScript inferred x is a number. I am just wondering if this could be possible the type inference could backtrack the type of param, also as a number?
The text was updated successfully, but these errors were encountered:
yahiko00
changed the title
Infering type of function parameters from usage
Inferring type of function parameters from usage
Jul 3, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
When dealing with large JavaScript codebases, it would be convenient if TypeScript could infer the type of function parameters from their usage in the body.
As a short example:
TypeScript inferred
x
is a number. I am just wondering if this could be possible the type inference could backtrack the type ofparam
, also as anumber
?The text was updated successfully, but these errors were encountered: