Skip to content

TypeScript Support

Ivo Yankulovski edited this page May 13, 2023 · 7 revisions

Install node @types by command:

npm install @types/node -g

npm install @types/node --save-dev

Link to NPM

Link to GitHub

Another way is to copy-paste the global updated directory of @types/node into repo node_modules/@types.

Execution of Scripts Error

File HDD:\npm\tsc.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
+ tsc <<<<  .\protoss-nodejs-basic
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

Use the following terminal snippet:

set-executionpolicy remotesigned

Configure TypeScript VSCode project

prettier and tsc

Install prettier globally:
npm install prettier -g

Use npm scripts to compile a project after building or examining tsconfig.json:
npm run tsc

or

npm run tsc-pretty

node_modules

Create folder on your file system and export/checkout/put all additional local or remote project folders.
Create folder node_modules and put symlinks of @types inside, so it can appear on top of code project.
Add symlinks of any other folder and configure workspace environment to follow links on local system.
Use package.json to install github/npm dependencies and packages.

compiling

Compile separate tsconfig.json folders by calling from terminal:

tsc --project ./path-to-local-project/

or shortcode watch mode of the compiler:

tsc -p ./path-to-local-project/ -w

Terminate the batch process using CTRL+C and type Y.