A basic TypeScript project setup.
These instructions will help you get the project up and running on your local machine.
Make sure you have Node.js and npm installed. You can download them from https://nodejs.org/.
- Clone the repository.
- Navigate to the project directory:
cd ts-boilerplate
- Install the dependencies:
npm install
To build the TypeScript project and compile it into JavaScript, run the following command:
npm run build
This will create a dist
directory containing the compiled JavaScript files.
To run the compiled JavaScript code, use the following command:
npm start
This will execute the index.js
file located in the dist
directory and you should see "Hello John Doe!" printed in the console.
For a better development experience, you can run the project without building it first using the following command:
npm run dev
This uses ts-node
to execute the TypeScript code directly, which is useful during development as it reflects changes immediately without the need to build the project each time.
This project uses ESLint for linting and Prettier for code formatting to maintain code quality and consistency.
Linting
To run the linter, use the following command:
npm run lint
(Note: The --ext .ts
flag is no longer needed and has been removed from the lint
script in package.json
.)
Formatting
To check if the code is formatted, use the following command:
npm run format
To automatically format the code, use the following command:
npm run format:fix
The project has a basic Continuous Integration (CI) setup using GitHub Actions. On each push to the main
branch and on each pull request, the CI workflow will:
- Install dependencies.
- Run the linter.
- Check the code formatting.