DEV Community

Cover image for 🗾️ TypeScript Customers Info With MapBox
alexpaper
alexpaper

Posted on

2 1

🗾️ TypeScript Customers Info With MapBox

Working with typescript especially in the beginning (I am a beginner 🤔️),
declaring the type of each variable, the syntax not always intuitive, can be very frustrating! 😤️

The code stretches a lot but the advantages in the long run are undeniable! 🤓️

In this video guide i created a litle customer page to get familiar with typescript sintax, for example, when you fetch some customer info you need to declare in advance the object type using ** interface **

// User Interface
interface User {
    name: string;
    username: string;
    email: string;
    address:{
        street: string;
        suite: string;
        city: string;
        zipcode: string;
        geo:{
            lat: string;
            lng: string;
        }
    };
    phone: string;
    website: string;
    company: {
        name:string;
        catchPhrase: string;
        bs:string;
    };
};

Enter fullscreen mode Exit fullscreen mode

In this way typescript knows what kind of data to expect, and if there is something wrong, report it in advance!

To view the customer coordinates I used MapBox

Hope this little exercise helps you better understand the importance of typescript in your code!

Video Guide

Have a nice day!
🖐️

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more