Closed atom-morgan closed 8 years ago
Hey @atom-morgan, in some places, the types of each parameter can be inferred.
In the second case, TypeScript can figure out the parameter types, because it know the type of app.get
. But in the first, it's harder to tell what consumers (if any) might use the index
function. So without type annotations, TypeScript would've taken the most lenient route and picked any
for each parameter.
If you'd like to know the places where TypeScript would've picked any out, you can use the --noImplicitAny
compiler option, where the compiler will flag locations where it couldn't pick a better type.
I think that makes sense. Thanks for your response!
In index.ts the
req
andres
objects have their type specified.But in app.ts they're missing.
app.get('/user/:userid', (req, res) => { };
I'm in the process of converting an ES6 Express API to TypeScript and was wondering if there is a reason for this.