Dark mode
Setting Up package.json
เริ่มต้นโปรเจค TypeScript ด้วยการสร้างไฟล์ package.json:
bash
bun init -y
เพิ่ม dependencies ที่จำเป็น:
bash
bun add typescript
bun add -d @types/node
Creating tsconfig.json
สร้างไฟล์ configuration สำหรับ TypeScript:
bash
npx tsc --init
ตัวอย่าง tsconfig.json พื้นฐาน:
json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "bundler",
"outDir": "./dist"
},
"include": ["src/**/*"]
}
Project Structure
โครงสร้างโปรเจคแนะนำ:
project/
├── src/
│ └── index.ts
├── dist/ # compiled output
├── tsconfig.json
└── package.json