A minimalist typescript cheatsheet to get started quickly
// Install typescript
npm install -g concurrently lite-server typescript
// Run the .ts
tsc typescript-cheatsheet --watch
| const cluster = require('cluster'); | |
| const chokidar = require('chokidar'); | |
| function start() { | |
| // do something here | |
| console.log('START >>'); | |
| } | |
| function hot(start, files) { | |
| if (typeof files == 'string') files = [files]; |
| const express = require('express') | |
| const app = express() | |
| app.get('/', (req, res) => { | |
| res.status(200) | |
| .contentType('application/json') | |
| .json({ hello: 'world' }) | |
| }) |
| type Props = { [key: string]: object | string }; | |
| // Classbase just declares any class that must have a display name and are constructible | |
| interface ClassBase { | |
| displayName: string; | |
| // new?(): Props; | |
| } | |
| // Declare UserHandler interface | |
| interface UserHandler extends ClassBase { |
| #include <fstream> | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| using namespace std; | |
| void learnTypesAndSize() { | |
| /** TYPES */ | |
| cout << "\n:::: TYPES ::::" << endl; |
| // PARENT | |
| const query = graphql.experimental` | |
| query MyRootComponentQuery($employeeId: String!, $includeOvertime: Boolean) { | |
| employee(id: $employeeId) { | |
| fullName | |
| ...MyFragmentComponent_employee @arguments(includeOvertime: $includeOvertime) | |
| } | |
| } | |
| ` |
| #! /bin/bash | |
| # ------------------------------------------------------------ | |
| # Downloads required packages | |
| # ------------------------------------------------------------ | |
| # Realize is a Golang Task Runner performing live reloading | |
| if [ ! -f $GOPATH/bin/realize ] && [ ! -d $GOPATH/src/github.com/oxequa/realize ]; then | |
| echo "Realize not found. Downloading it for you..." |
| import React from 'react'; | |
| const initialData = "hello from initial data" | |
| function iterateOverChildren(children) { | |
| return React.Children.map(children, child => { | |
| if (!React.isValidElement(child)) { | |
| return child; | |
| } | |