Skip to content

Instantly share code, notes, and snippets.

@namhnz
Created October 1, 2020 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namhnz/d6cc3c89a92bd28c27e6de04a5226fc5 to your computer and use it in GitHub Desktop.
Save namhnz/d6cc3c89a92bd28c27e6de04a5226fc5 to your computer and use it in GitHub Desktop.
1. https://levelup.gitconnected.com/how-to-set-up-a-typescript-node-js-app-in-5-minutes-93ffee3b1768
Setting Up TypeScript
First create a project a folder:
mkdir typescript-api
cd typescript-api
Initialize your package.json:
yarn init -y
The first package we’ll install is typescript as a dev dependency. The reason we use TypeScript as a dev dependency is that before we deploy our app to production, we compile TypeScript to normal JavaScript code that can be interpreted by Node.
yarn add -D typescript
Every TypeScript project must have a tsconfig.json file at the root of it so we can configure it to the specification of our project. After installing TypeScript, we have access to the tsc command within our project. We can initialize a tsconfig.json file executing the following command:
yarn tsc --init --rootDir src --outDir dist
2. https://galdin.dev/blog/writing-a-node-console-app-in-typescript/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment