📁
Notes
  • About
  • Unreal Engine
    • UI
      • Menu & Menu Bar
    • Math
    • Serialize
    • Pipeline
    • 🚀Automation
    • UE Cpp
    • Uncategorized
  • Type Script
    • Setup
  • Tool
    • V2Ray on Ubuntu
Powered by GitBook
On this page
  • Prerequisite
  • Install Node.js
  • Install
  • Configure Project
  • Use Visual Studio Code
  • Configure the eslint
  • Create launch configure
  1. Type Script

Setup

Guide to setup typescript development environment

PreviousType ScriptNextTool

Last updated 2 years ago

Prerequisite

Install Node.js

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

tsconfig.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"
    ],
}

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

.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 }]
    },

}

Create launch configure

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

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

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"
            ]
        }
    ]
}

Node.jsNode.js
Logo