An open API service indexing awesome lists of open source software.

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

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
```