Skip to content

Instantly share code, notes, and snippets.

View thebeebs's full-sized avatar
🏠
Working from home

Martin Beeby thebeebs

🏠
Working from home
View GitHub Profile
@thebeebs
thebeebs / IntroduceTypescript
Created February 12, 2014 18:41
If I annotate x as a string things start to light up In sublime. You will nottice errors being thrown in the code below it is saying that a string can't have a name property.
function process(x: string){
x.name = "foo";
var v = x + x;
alert(v);
}
@thebeebs
thebeebs / Vanilla JS
Last active August 29, 2015 13:56
An ordinary function in JavaScript.
function process(x){
x.name = "foo";
var v = x + x;
alert(v);
}
@thebeebs
thebeebs / gist:8955250
Created February 12, 2014 13:07
You can define you own types using interfaces Thing describes and object literal with an a number property and a b string property. Even though the process function dosen't return a type We have given the compiler enogh information to infer that n at the bottom will be of type number.
//
interface Thing {
a: number;
b: string;
c: boolean;
}
function process(x: Thing){
return x.a;