Skip to content

Instantly share code, notes, and snippets.

View danwbyrne's full-sized avatar
🌞
Focusing

Daniel Byrne danwbyrne

🌞
Focusing
View GitHub Profile
@danwbyrne
danwbyrne / Typescript-typing-recipes.md
Last active August 3, 2018 18:34
Typescript typing recipes

Useful Type Rules That Saves You Looking It Up

Reduce

let count = -1;
const array = ReadonlyArray<T>;

array.reduce<{[k in string]: T}>((acc: {[k in string]: T}, entry) => ({
  //              ^-->acc-type               ^--->acc-type
 count = count + 1;
console.log packages\neo-one-smart-contract-compiler\src\createContext.ts:132
getScriptSnapshot fileName: C:\Users\Dan\desktop\neo-one\packages\neo-one-smart-contract\src\global.d.ts
console.log packages\neo-one-smart-contract-compiler\src\createContext.ts:126
getScriptVersion fileNameIn: C:\Users\Dan\desktop\neo-one\packages\neo-one-smart-contract\src\global.d.ts
console.log packages\neo-one-smart-contract-compiler\src\createContext.ts:132
getScriptSnapshot fileName: C:\Users\Dan\desktop\neo-one\packages\neo-one-smart-contract\src\sc.d.ts
console.log packages\neo-one-smart-contract-compiler\src\createContext.ts:126
#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
class BstNode {