# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://auchan.gitbook.io/notes/type-script/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
