Skip to content

Instantly share code, notes, and snippets.

@mckernanin
Created August 31, 2018 00:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mckernanin/07a4b130f1ed846eb1b6f73dc4a87acb to your computer and use it in GitHub Desktop.
Save mckernanin/07a4b130f1ed846eb1b6f73dc4a87acb to your computer and use it in GitHub Desktop.
Scaffold a typescript project quickly
#!/bin/bash
yarn add dotenv express joi lodash morgan
yarn add -D nodemon ts-node types-installer typescript add-npm-scripts
yarn add-npm-scripts start "nodemon"
yarn add-npm-scripts build "tsc"
yarn types-installer
cat > nodemon.json <<EOL
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --inspect -r ts-node/register ./src/index.ts"
}
EOL
cat > tsconfig.json <<EOL
{
"compilerOptions": {
"module": "commonjs",
"target": "es2016",
"noImplicitAny": false,
"strictNullChecks": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*",
"src/*"
]
},
"typeRoots": [
"./node_modules/@types",
"./src/typings"
],
"rootDirs": [
"src/"
],
"types": [
"node"
]
},
"include": [
"src/**/*"
]
}
EOL
mkdir -p src
cat > src/index.ts <<EOL
console.log('hello world!');
EOL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment