A browser-based TypeScript project built using HTML5, TailwindCSS, TypeScript, Node.js, and Vite.
This project is designed as a single complete assignment to demonstrate core TypeScript concepts and browser project setup in a structured, professional way.
This assignment covers the following TypeScript concepts and requirements:
- Set up a basic Node.js or browser project with TypeScript
- Define interfaces and custom types for simple data structures
- Practice explicit type annotation for variables and function signatures
- Implement a function that uses generic types to ensure type safety
- Experiment with type assertion and understand how TypeScript infers types
- Write a small program that utilizes enums and tuples
Instead of creating multiple disconnected examples, this project combines all requirements into one practical mini application.
A browser-based dashboard application that demonstrates:
- Product listing
- Inventory management
- Product status tracking
- Typed data rendering
- Generic helper utilities
- DOM interaction with TypeScript
- TailwindCSS UI styling
- HTML5
- TailwindCSS
- TypeScript
- Vite
- Node.js
- npm
Installed:
- Node.js
- npm
- VS Code
Recommended VS Code Extensions:
- Tailwind CSS IntelliSense
- Prettier
- TypeScript Hero
- Error Lens
- Auto Rename Tag
mkdir typescript-assignment
cd typescript-assignmentnpm init -yGenerated:
package.json
Purpose:
- project metadata
- dependency management
- scripts
npm create vite@latest . -- --template vanilla-tsPurpose:
Creates a browser-based TypeScript starter project.
Generated:
index.html
src/
tsconfig.json
vite.config.ts
package.json
npm installGenerated:
node_modules/
package-lock.json
Installed:
- TypeScript
- Vite
- Vite internal dependencies
npm install tailwindcss @tailwindcss/viteInstalled:
- tailwindcss
- @tailwindcss/vite
Updated:
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [tailwindcss()],
});Updated:
@import "tailwindcss";npm run devExpected:
http://localhost:5173
Setup verification successful.
typescript-assignment/
│
├── node_modules/
│
├── src/
│ │
│ ├── types/
│ │ └── index.ts
│ │
│ ├── data/
│ │ └── products.ts
│ │
│ ├── utils/
│ │ └── helpers.ts
│ │
│ ├── constants/
│ │ └── config.ts
│ │
│ ├── components/
│ │ ├── productCard.ts
│ │ ├── statsPanel.ts
│ │ └── inventoryTable.ts
│ │
│ ├── app.ts
│ ├── main.ts
│ └── style.css
│
├── index.html
├── package.json
├── package-lock.json
├── tsconfig.json
├── vite.config.ts
└── README.md
Contains TypeScript definitions:
- interfaces
- custom types
- enums
- tuples
Examples:
- Product interface
- Product category type
- Stock status enum
- Cart tuple
Contains static application data.
Examples:
- product list
- inventory records
Contains reusable helper functions.
Examples:
- generic functions
- currency formatter
- filters
- utility logic
Contains fixed configuration values.
Examples:
- app name
- currency symbol
- UI labels
Contains modular UI rendering logic.
Examples:
- product cards
- dashboard stats
- inventory table
Core application logic.
Responsibilities:
- rendering
- event handling
- DOM interaction
- TypeScript feature demonstrations
Application entry point.
Loads:
- styles
- app bootstrap logic
TailwindCSS import + custom styling.
Browser entry point.
Contains:
- HTML5 structure
- app root
- script loading
This project is designed to demonstrate:
Example:
let totalProducts: number = 10;Example:
let appName = "Product Dashboard";Example:
interface Product {}Example:
type ProductCategory = "Electronics" | "Books";Example:
enum StockStatus {}Example:
type CartItem = [number, string, number];Example:
function getFirstItem<T>()Example:
document.querySelector() as HTMLDivElementExample:
function calculateTotal(price: number): number| Requirement | Covered |
|---|---|
| Set up TypeScript browser project | In Progress |
| Interfaces | Planned |
| Custom types | Planned |
| Explicit type annotations | Planned |
| Generic function | Planned |
| Type assertion | Planned |
| Type inference | Planned |
| Enums | Planned |
| Tuples | Planned |
Create:
src/types/index.ts
Implement:
- Product interface
- Inventory interface
- custom type aliases
- StockStatus enum
- Cart tuple
Goal:
Strong TypeScript foundation.
Create:
src/data/products.ts
Implement:
- typed product array
- mock inventory data
Goal:
Use interfaces practically.
Create:
src/utils/helpers.ts
Implement:
- generic reusable function
- currency formatter
- filter helpers
- explicit return types
Goal:
Demonstrate generics + explicit typing.
Create:
src/constants/config.ts
Implement:
- app title
- currency config
- labels
Goal:
clean architecture.
Create:
src/components/
Implement:
Generate product card HTML.
Dashboard statistics.
Inventory listing.
Goal:
modular browser UI.
Create:
src/app.ts
Implement:
- render logic
- event handlers
- DOM manipulation
- type assertion
- type inference examples
Goal:
core application behavior.
Update:
src/main.ts
Implement:
- import styles
- initialize application
Goal:
bootstrap project correctly.
Update:
index.html
Implement:
- semantic HTML5 structure
- dashboard root container
Goal:
HTML5 compliance.
Use:
- Tailwind utility classes
Implement:
- responsive layout
- cards
- tables
- buttons
- dashboard sections
Goal:
clean professional UI.
Verify:
npm run devCheck:
- rendering works
- no TS errors
- all assignment requirements satisfied
Completed project will include:
- Product dashboard
- Product cards
- Inventory status
- Dashboard stats
- Typed data structures
- Generic utility functions
- DOM interaction
- Tailwind UI
- Full TypeScript assignment coverage
Development:
npm run devBuild:
npm run buildPreview:
npm run previewDeliver a clean, professional, browser-based TypeScript project that demonstrates all assignment requirements in one cohesive application.