<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: krishankant singhal</title>
    <description>The latest articles on DEV Community by krishankant singhal (@krishankant).</description>
    <link>https://dev.to/krishankant</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F221356%2Ff8fb51c6-8d56-4ab0-b280-4d798e98a3e3.jpeg</url>
      <title>DEV Community: krishankant singhal</title>
      <link>https://dev.to/krishankant</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/krishankant"/>
    <language>en</language>
    <item>
      <title>Blog Post 2: TypeScript Basics and Our First POS Component</title>
      <dc:creator>krishankant singhal</dc:creator>
      <pubDate>Tue, 01 Oct 2024 03:54:07 +0000</pubDate>
      <link>https://dev.to/krishankant/log-post-1-introduction-to-typescript-and-our-restaurant-pos-project-49ai</link>
      <guid>https://dev.to/krishankant/log-post-1-introduction-to-typescript-and-our-restaurant-pos-project-49ai</guid>
      <description>&lt;p&gt;Welcome back! In this post, we’ll cover some TypeScript basics and create our first component for the Restaurant POS system.&lt;/p&gt;

&lt;p&gt;Let’s start with some key TypeScript concepts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Static Typing&lt;/strong&gt;
TypeScript’s main advantage is its static typing system. Let’s look at an example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    let tableNumber: number = 5;
    let serverName: string = “John Doe”;
    let isOccupied: boolean = false;
    // This would cause a compile-time error
    // tableNumber = "Six"; // Type 'string' is not assignable to type 'number'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Interfaces&lt;/strong&gt;
Interfaces allow us to define the structure of objects:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    interface MenuItem {
     id: number;
     name: string;
     price: number;
     category: string;
    }
    const burger: MenuItem = {
     id: 1,
     name: "Cheeseburger",
     price: 9.99,
     category: "Main Course"
    };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s create our first component: a simple menu item display.&lt;/p&gt;

&lt;p&gt;Create a new file &lt;code&gt;src/components/MenuItem.tsx&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from ‘react’;
interface MenuItemProps {
 id: number;
 name: string;
 price: number;
 category: string;
}
const MenuItem: React.FC&amp;lt;MenuItemProps&amp;gt; = ({ id, name, price, category }) =&amp;gt; {
 return (
 &amp;lt;div className="menu-item"&amp;gt;
 &amp;lt;h3&amp;gt;{name}&amp;lt;/h3&amp;gt;
 &amp;lt;p&amp;gt;Price: ${price.toFixed(2)}&amp;lt;/p&amp;gt;
 &amp;lt;p&amp;gt;Category: {category}&amp;lt;/p&amp;gt;
 &amp;lt;/div&amp;gt;
 );
};
export default MenuItem;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, let’s use this component in our &lt;code&gt;App.tsx&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from ‘react’;
import MenuItem from ‘./components/MenuItem’;
const App: React.FC = () =&amp;gt; {
 const sampleMenuItem = {
 id: 1,
 name: "Cheeseburger",
 price: 9.99,
 category: "Main Course"
 };
return (
 &amp;lt;div className="App"&amp;gt;
 &amp;lt;h1&amp;gt;Restaurant POS&amp;lt;/h1&amp;gt;
 &amp;lt;MenuItem {…sampleMenuItem} /&amp;gt;
 &amp;lt;/div&amp;gt;
 );
};
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This example demonstrates how TypeScript helps us ensure that we’re passing the correct props to our components. If we tried to pass an invalid prop or omit a required one, TypeScript would alert us at compile-time.&lt;/p&gt;

&lt;p&gt;In our next blog post, we’ll expand on this by creating a menu list component and introduce some more advanced TypeScript concepts like generics and union types.&lt;/p&gt;

&lt;p&gt;To wrap up, let’s visualize the component structure we’ve created so far:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnut2yoc1njf49ttfp32a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnut2yoc1njf49ttfp32a.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This diagram shows our current simple structure, with the App component rendering a MenuItem component. As we progress, we’ll see this structure grow more complex.&lt;/p&gt;

&lt;p&gt;Stay tuned for our next post where we’ll dive deeper into TypeScript and expand our POS system’s functionality!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Post 1: Introduction to TypeScript and Our Restaurant POS Project</title>
      <dc:creator>krishankant singhal</dc:creator>
      <pubDate>Tue, 01 Oct 2024 03:51:34 +0000</pubDate>
      <link>https://dev.to/krishankant/post-1-introduction-to-typescript-and-our-restaurant-pos-project-4ogf</link>
      <guid>https://dev.to/krishankant/post-1-introduction-to-typescript-and-our-restaurant-pos-project-4ogf</guid>
      <description>&lt;p&gt;&lt;strong&gt;Blog Post 1: Introduction to TypeScript and Our Restaurant POS Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today, we’re embarking on an exciting journey to build a restaurant POS system using TypeScript and React. This project will not only teach you TypeScript concepts but also give you hands-on experience in creating a real-world application.&lt;/p&gt;

&lt;p&gt;Let’s start with an overview of our project structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54dgac968krsr4jhmebp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54dgac968krsr4jhmebp.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our Restaurant POS application will consist of a frontend built with React and TypeScript, and a backend using Node.js, Express, and TypeScript. This structure allows us to leverage TypeScript’s benefits throughout our entire stack.&lt;/p&gt;

&lt;p&gt;Key Features of Our POS System:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User Authentication&lt;/li&gt;
&lt;li&gt;Menu Management&lt;/li&gt;
&lt;li&gt;Order Taking&lt;/li&gt;
&lt;li&gt;Table Management&lt;/li&gt;
&lt;li&gt;Billing and Payments&lt;/li&gt;
&lt;li&gt;Reporting and Analytics&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let’s set up our development environment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install Node.js (if not already installed)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install TypeScript globally:
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a new React project with TypeScript:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app restaurant-pos —-template typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Navigate to the project directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd restaurant-pos
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great! We now have a basic React application with TypeScript set up. In our next blog post, we’ll dive into TypeScript basics and start building our first component for the POS system.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
