> For the complete documentation index, see [llms.txt](https://auchan.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://auchan.gitbook.io/notes/type-script/setup.md).

# Setup

## Prerequisite

### Install Node.js

{% embed url="<https://nodejs.org/en/>" %}

## Install

Install typescript via npm: `npm install typescript --save-dev`

## Configure Project

Use `tsc --init` to create a default 'tsconfig.json' or use below template

{% code title="tsconfig.json" %}

```json
{
    "compilerOptions": {
        "outDir": "dist",
        "preserveConstEnums": true,
        "target": "ES2015",
        "module": "commonjs",
        "strict": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ],
}
```

{% endcode %}

Use `tsc --watch` to watch and compile .ts files to .json files

## Use Visual Studio Code

Install eslint plugin in Visual Studio Code and eslint module via npm: `npm install eslint`

### Configure the eslint

{% code title=".eslintrc.json" %}

```
{
    "env": {
        "browser": true,
        "es6": true
    },
    "extends": [
        "standard"
    ],
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
        "quotes": ["error", "double"],
        "space-before-function-paren": ["error", "never"],
        "no-unused-vars": ["warn", { "vars": "local", "args": "after-used", "ignoreRestSiblings": false }],
        "no-trailing-spaces": ["warn", { "skipBlankLines": true, "ignoreComments": true }]
    },

}
```

{% endcode %}

### Create launch configure

Open menu Run -> Add Configureation then select Node.js

![](/files/UGaNlXa6TaGFdx8pD4Xu)

Editing launch.json. Notice the entrypoint is dist/index.js

{% code title="launch.json" %}

```
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            //
            "program": "dist/index.js",
            "outFiles": [
                "${workspaceFolder}/**/*.js"
            ]
        }
    ]
}
```

{% endcode %}
