Right, It made more sense after reading more about it. I think the discoverability in general is such a nice thing you get by going with static types that is almost worth it by that alone haha
Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
But, Typescript knows that name is a string and anywhere I use name, either as a parameter or in an assignment or expression, Typescript will flow that string type to the next place I'm working with name.
A lot of developers when first using Typescript will add a ton of annotations to their code, only to realize later that Typescript is great at inferring type information and doesn't need us to be so explicit.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Right, It made more sense after reading more about it. I think the discoverability in general is such a nice thing you get by going with static types that is almost worth it by that alone haha
Another nice thing about Typescript is how the types "flow" through the application.
Often I only need to annotate a couple of parameters, variables, methods.
Then when using those things the rest of my code is able to infer the results of operations.
For example:
Notice, there are 0 type annotations here...
But, Typescript knows that
name
is astring
and anywhere I use name, either as a parameter or in an assignment or expression, Typescript will flow thatstring
type to the next place I'm working withname
.A lot of developers when first using Typescript will add a ton of annotations to their code, only to realize later that Typescript is great at inferring type information and doesn't need us to be so explicit.