DEV Community

Abhay Nikam
Abhay Nikam

Posted on

2 1

Day 1-2 - Started with 100 days of coding challenge to learn TypeScript

I publicly(on twitter) committed to the 100DaysOfCode Challenge yesterday and started with learning TypeScript.

I am completing a TypeScript course on Udemy - Typescript: The Complete Developer's Guide

Day 1: Started learning TypeScript

Completed with the introduction and basic environment setup for TypeScript.

Day 2: Executed the first TypeScript code.

The main goal of TypeScript is to catch the errors in the development phase. Started with a simple example to fetch static JSON data and pretty-print the response data.

Wrote an interface in TypeScript. Interfaces in TypeScript are used to define the structure of the object. Adding interface helped in catching the error in development if wrong JSON key was used.

Here is the first index.ts I wrote:

import axios from "axios";

const url = "https://jsonplaceholder.typicode.com/todos/1";

interface Todo {
  id: number;
  title: string;
  completed: boolean;
}

axios.get(url).then(response => {
  const todo = response.data as Todo;

  const id = todo.id;
  const title = todo.title;
  const completed = todo.completed;

  logTodo(id, title, completed);
});

const logTodo = (id: number, title: string, completed: boolean) => {
  console.log(`
    The Todo with ID : ${id}
    Has a title of: ${title}
    Is it finished? ${completed}
  `);
};

Happy coding fellas.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

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