DEV Community

Abhay Nikam
Abhay Nikam

Posted on

2

Day 3/100 - The basics of types in TypeScript

On the third day of 100daysofcode challenge, learned the basics of types in TypeScript.

What are types?

Types in TypeScript are just a simple way to describe the properties and function of a value.

For example:

const name = "Abhay Nikam"

The variable name is of type string which has different properties and function.

// Example of some properties for type string value
name.charAt();
name.indexOf();

Types are of two categories:

  1. Primitive Types: number, boolean, void, undefined, string, symbol, null.
  2. Object Types: functions, arrays, classes, objects.

NOTE: I haven't yet studied all types in details. Will be learning
that in the next few days.

Why do we care about types?

There is a simple answer to this question. We care about types because types give the required information to the TypeScript compiler to analyze the value and throw an error if something is not as per type defined.

Types also help the other developers in the team to understand what properties and function value might have.

Where to use types?

EVERYWHERE!!

Happy Friday. Happy Coding.

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay