Skip to content

Commit fdbeba1

Browse files
committed
Update README.MD
1 parent 0c5864a commit fdbeba1

File tree

1 file changed

+69
-28
lines changed

1 file changed

+69
-28
lines changed

README.MD

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,94 @@
11
# TypeScript Template
22

3-
This is a template repository for starting a new TypeScript project.
3+
A modern, minimal template for starting TypeScript projects on Node.js with sensible defaults and a smooth developer experience.
44

5-
## Getting Started
5+
## Features
66

7-
### Prerequisites
7+
- TypeScript 5 with strict mode and Node LTS (22) aligned config
8+
- Fast iteration using `ts-node` for development
9+
- ESLint (typescript-eslint) and Prettier for consistent, high‑quality code
10+
- Environment variables via `dotenv`
11+
- Dependency management with `pnpm`
812

9-
- [Node.js](https://nodejs.org/)
10-
- [pnpm](https://pnpm.io/)
13+
## Prerequisites
1114

12-
### Installation
15+
- Node.js 20 or 22+ (LTS recommended)
16+
- pnpm 10+
1317

14-
1. Clone the repository:
18+
## Quick Start
1519

16-
```sh
17-
git clone https://github.com/your-username/typescript-template.git
18-
cd typescript-template
19-
```
20+
- Clone and install dependencies:
2021

21-
2. Install dependencies using pnpm:
22+
```sh
23+
git clone https://github.com/sajaddp/typescript-template.git
24+
cd typescript-template
25+
pnpm i
26+
```
2227

23-
```sh
24-
pnpm i
25-
```
28+
- Configure environment variables:
2629

27-
### Running the Project
30+
- Create a `.env` file in the project root (if it doesn’t exist) and set:
2831

29-
To run the project, use the following command:
32+
```env
33+
MY_SECRET="your-secret-value"
34+
```
35+
36+
- Run in development mode:
3037

3138
```sh
32-
ts-node ./src/index.ts
39+
pnpm dev
3340
```
3441

35-
### Development
42+
The app logs the value of `MY_SECRET` to the console.
3643

37-
To start the development server, run:
44+
## Scripts
3845

39-
```sh
40-
npm run dev
41-
```
46+
- `pnpm dev`: Run the app with `ts-node` from `src/index.ts`.
47+
- `pnpm build`: Compile TypeScript with `tsc`.
48+
- `pnpm prettier`: Format code in `src` using Prettier.
4249

43-
### Code Formatting
50+
Note: After `pnpm build`, JavaScript output is emitted alongside the `.ts` files by default. You can set `outDir` in `tsconfig.json` (e.g., `dist`) and then run `node dist/index.js`.
4451

45-
To format the code using Prettier, run:
52+
## Project Structure
4653

47-
```sh
48-
npm run prettier
54+
```txt
55+
.
56+
├── src/
57+
│ └── index.ts # Entry point (example: reading an env variable)
58+
├── eslint.config.mjs # ESLint configuration with typescript-eslint
59+
├── tsconfig.json # TypeScript configuration aligned with Node 22
60+
├── package.json # Scripts and dependencies
61+
├── .env # Local environment variables
62+
└── README.MD
4963
```
5064

65+
## Code Quality
66+
67+
- ESLint: Lint TypeScript/JS code
68+
69+
```sh
70+
pnpm exec eslint . --ext .ts
71+
```
72+
73+
- Prettier: Enforce consistent formatting
74+
75+
```sh
76+
pnpm prettier
77+
```
78+
79+
## TypeScript Settings
80+
81+
- Target: `es2023`
82+
- Module/Resolution: `node16`
83+
- Enabled: `strict: true`, `esModuleInterop: true`, `resolveJsonModule: true`
84+
85+
To emit compiled files into a separate directory, enable `outDir` in `tsconfig.json`.
86+
87+
## Troubleshooting
88+
89+
- Missing env value: Ensure `.env` exists and `MY_SECRET` is defined, then run with `pnpm dev`.
90+
- Where is the build output? Without `outDir`, `.js` files are emitted next to `.ts`. Either run `node src/index.js` or configure `outDir` (e.g., `dist`) and run `node dist/index.js`.
91+
5192
## License
5293

53-
This project is licensed under the MIT License.
94+
Released under the MIT License.

0 commit comments

Comments
 (0)