Skip to content

Instantly share code, notes, and snippets.

@spion
Last active August 29, 2015 14:27
Show Gist options
  • Save spion/3edbafef55f4975e19c9 to your computer and use it in GitHub Desktop.
Save spion/3edbafef55f4975e19c9 to your computer and use it in GitHub Desktop.
Initialize typescript/react project
tsc
browserify lib/main.js -o bundle.js -d
# This is where we will keep definitions of external libraries
# e.g. https://github.com/borisyankov/DefinitelyTyped/blob/master/react/react.d.ts
mkdir d.ts
# Our sources will go here
mkdir src
# Compiled JS and sourcemaps go here
mkdir lib
# We need to initialize our package.json to store dependencies
npm init
# Add react
npm install --save react
# Add react definitions
curl https://raw.githubusercontent.com/borisyankov/DefinitelyTyped/master/react/react.d.ts > d.ts/react.d.ts
npm install -g typescript browserify watchify
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"outDir": "lib/",
"sourceMap": true,
"noLib": false,
"target": "es5",
"declaration": false,
"jsx": "react"
},
"filesGlob": [
"d.ts/**/*.d.ts",
"src/**/*.ts"
]
}
tsc -w &
watchify lib/main.js -o lib.bundle.js -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment