Type Inference inTypeScript – Defining Inferred type

TypeScript tries to infer as many types as possible by default in certain cases. It tries to know which types are used without us explicitly states it.

eg:

let subject = ' Learn typescript '

Here in the above example, we immediately initialized it with string data. Here Typescript will look at the value type here. So it will see that we stored a string in that variable and then use that as a value type as an inferred type for its variable.

About the Author: smartcoder

You might like

Leave a Reply

Your email address will not be published. Required fields are marked *