new-typescript-guidelines
Installation
SKILL.md
TypeScript Guidelines (Next.js App Router)
This skill outlines the TypeScript style guide, folder structure, and coding conventions for the KruChiron project. Adhere to these principles to ensure type safety, consistency, and clean code across the codebase.
Core Principles
- ใช้
typeแทนinterfaceตามแนวทางโปรเจกต์ - เปิด
strictmode ในtsconfig.json - หลีกเลี่ยง
anyทุกกรณี ใช้unknownหากจำเป็น - ใช้
readonlyกับค่าที่ไม่ควรแก้ไข - ใช้
as constกับตัวแปรคงที่ที่ใช้ซ้ำหลายจุด
Folder Structure
- เก็บ type กลางไว้ที่
src/types - API response types อยู่ใน
src/types/api - Component props แยกเป็นไฟล์ เช่น
[component-name].types.ts - Domain-specific types จัดกลุ่มตาม feature module
- แยก type สำหรับ server และ client หากมี dependency ต่างกัน