https://github.com/chrisdothtml/minimal-node-ts-starter
A minimal example of using node's built-in support for running and testing Typescript code
https://github.com/chrisdothtml/minimal-node-ts-starter
no-build nodejs typescript
Last synced: 2 months ago
JSON representation
A minimal example of using node's built-in support for running and testing Typescript code
- Host: GitHub
- URL: https://github.com/chrisdothtml/minimal-node-ts-starter
- Owner: chrisdothtml
- Created: 2025-02-12T22:11:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-14T07:06:09.000Z (over 1 year ago)
- Last Synced: 2025-02-14T07:33:36.131Z (over 1 year ago)
- Topics: no-build, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# minimal-node-ts-starter
- Uses node's `--experimental-transform-types` ([docs](https://nodejs.org/api/typescript.html#type-stripping)), so you can execute TypeScript files directly from node (so no build steps, and no `tsm`)
- Uses node's test runner
- Only dependencies are for typechecking and code linting/formatting
### Tools required
Neither of these are actually required, but having them offers the simplest/cleanest way to use this repo.
- [volta](https://volta.sh/) (for auto-installing/loading node/yarn from package.json config)
- [direnv](https://direnv.net/docs/installation.html) (for loading `NODE_OPTIONS` from `.envrc`)
This repo also comes with vscode settings for auto-formatting and validating the code, just make sure you have the recommended extensions installed.
### Try it out
```sh
# enable direnv in this dir
direnv allow
# run program
node ./src/index.ts
# install deps for local validators
yarn install
# lint files with prettier (`lint-fix` to fix errors)
yarn lint
# run Typescript validations
yarn typecheck
# run tests
yarn test
# run a single test file
yarn test ./src/__tests__/utils.test.ts
```