Giter VIP home page Giter VIP logo

starter's Introduction

VSCode TypeScript node starter

Starter for developing Node apps in TypeScript with setup for VSCode debugging with no global dependencies.

The follwing is setup out of the box:

Prerequisites

To start, node is required.

npm (Node Package Manager) or yarn can be used as package managers.

The TypeScript Compiler (tsc) is included and not required in your path.

Getting started

Fork the repo and clone to your local machine, open a terminal / command line and get base packages:

via npm

    npm install

via yarn

    yarn

The src/index.ts is your entry point, it has an StartUp class that is called to start your application! Add additional files to the src folder and import to your src/index.ts file to use as per the hello_world example.

Adding 3rd Party Packages

Open a terminal / command line, add a package:

via npm

    npm install packageName --save

via yarn

    yarn add packageName

If typings are missing/not included with the base packge, the majority of popular npm packages have typing defined on npm under the @types scoping.

Install as dev dependancies:

via npm

    npm install @types/packageName --save-dev

via yarn

    yarn add @types/packageName -D

Linting

The project is setup with eslint and typescript-eslint. If you use VSCode linting feedback should appear in the editor as you type, you can also run linting on the project:

via npm

    npm run lint

via yarn

    yarn lint

Testing

The project is setup and configured with ts-jest to run Jest tests. Jest tests saved in the src folder will get picked up if the meet one of the following criteria:

  • ts/tsx files saved in __tests__ folders
  • files meeting the following patterns
    • *.test.ts
    • *.spec.ts

To run tests

via npm

    npm test

via yarn

    yarn test

There is a pre-test hook that runs tslint before tests are run.

There is a very useful plugin Jest (free), an integrated continuous testing tool that adds test feedback to the editor and session based test watching.

Another (multi-editor) integrated continuous testing plugin is the renowned Wallaby.js (paid) that this base setup works out of the box with.

Building

Running the Build task in VSCode will compile TypeScript (/src) to es2020 JavaSript (/dist).

Shortcut on Windows/Linux: Ctrl + Shift + B, macOS: Command + Shift + B

Debugging

Set breakpoints in your TS code and press F5 to start the debugger, happy debugging!

Running via ts-node

To run the your code:

via npm

    npm start

via yarn

    yarn start

This command uses ts-node to run your application using your tsconfig.json compile options, without compiling to JavaScript files.

Running Dev

To run the your code:

via npm

    npm run start:dev

via yarn

    yarn start:dev

This runs ts-node via nodemon so when changes are made the process is restarted for you.

Running Dev with Tests

To run the your code:

via npm

    npm run start:dev:test

via yarn

    yarn start:dev:test

This runs ts-node via nodemon so when changes are made the process is restarted for you, and tests rerun.

Live feedback

If you have Pro licence TS imports will work with Quokka.js

Customisations

For editor defaults, adjust editor.config.

To change linting, adjust .eslintrc.js.

Adjust the settings in tsconfig.json to change the compiled output.

starter's People

Contributors

lematecdosj avatar rempaut avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.