Skip to content

Instantly share code, notes, and snippets.

Working from home

Jonathan Creamer jcreamer898

Working from home
View GitHub Profile

Type 'from' in the editor and...


What even is TypeScript?

JavaScript + Types = Typescript

TypeScript as a compilter

npm i -g typescript


set -e
while [[ $# -gt 0 ]]
case $key in
jcreamer898 /
Created Jul 13, 2012
Using amplifyjs as with RequireJS 2.0

Using AmplifyJS with RequireJS 2.0

With the lastest version of Require, a new config object was introduced, the shim.

That allows Amplify to now be used within AMD projects.

Have Fun!

Name of thing Sorta like... Mounted? Can you even setState? What would you say... ya do here?
constructor initialize() nope nope init stuff NO side effects
componentWillMount beforeDomReady() nope yeah but don't Only needed in createClass now use constructor for most things
render render nope please no render stuff and don't set any state please
componentDidMount domReady() yup yup DOM is a go init jQuery plugins dispatch stuff
componentWillReceiveProps onChange() yup yup
View formatPriceJsDoc.ts
// @ts-check
* Format a price
* @param num {number} The price
* @param symbol {string} The currency symbol
const formatPrice = (num, symbol = "$") =>
View price.tsx
import * as React from "react";
import formatPrice from "../utils/formatPrice";
export interface IPriceProps {
num: number;
symbol: "$" | "€" | "£";
const Price: React.SFC<IPriceProps> = ({
View formatPrice.ts
const formatPrice = (num: number, symbol = "$": string) =>
`${symbol}${num.toFixed(2)}`; formatPrice("1234");
// num.toFixed is not a function
jcreamer898 / formatPrice.js
Last active Feb 2, 2018
Stuff for my typescript blog
View formatPrice.js
const formatPrice = (num, symbol = "$") =>
`${symbol}${num.toFixed(2)}`; formatPrice("1234");