samnoh / ts-bubble-sort

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript Bubble Sort

TIL

tsconfig.json

  • create tsconfig.json automatically
tsc --init --rootDir "./src" --outDir "./build"

concurrently

  • Run multiple commands concurrently
  • npm
npm install --save-dev concurrently
  • package.json
"scripts": {
    "start:run": "nodemon build/index.js",
    "start:tsc": "tsc -w",
    "start": "concurrently npm:start:*"
}

Abstract Classes

  • Strongly couples classes together
  • Informs child classes what methods they should have
abstract class Vehicle {
    abstract goTo(road: string): void
    abstract setOwner(name: string): void

    startEngine(): void {...}
}
class Car extends Vehicle {
    constructor() {
        super();
        ...
    }
}

Method Chaining

class Calculatr {
    constructor(public value: number) {}

    add(num: number): this {
        this.number += num;
        return this;
    }
}

const calc = new Calculator(1);
calc.add(1).add(10).add(4);

About


Languages

Language:TypeScript 100.0%