Skip to content

Instantly share code, notes, and snippets.

@osbornm
Created August 26, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osbornm/405ad9f76f352ab20279 to your computer and use it in GitHub Desktop.
Save osbornm/405ad9f76f352ab20279 to your computer and use it in GitHub Desktop.
JS vs TS
var things = [
new Thing1(),
new Thing1(),
new Thing2()
];
var OnlyThingOnes = things.filter(function(t){return t.thingOneOnlyProperty !== undefined});
things: (Thing1|Thing2)[];
//constructor code
this.things = [
new Thing1(),
new Thing1(),
new Thing2()
];
var OnlyThingOne = <Thing1[]>this.things.filter(m => (<thing1>m).thingOneOnlyProperty !== undefined);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment