├── .eslintrc ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── README.md ├── package.json ├── public └── index.html ├── src ├── @types │ └── question.d.ts ├── client │ ├── README.md │ ├── client.ts │ └── tsconfig.json └── server │ ├── README.md │ ├── server.ts │ └── tsconfig.json ├── tsconfig-base.json └── tsconfig.json /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "extends": [ 4 | "plugin:@typescript-eslint/recommended" 5 | ], 6 | "rules": { 7 | "@typescript-eslint/type-annotation-spacing" : [1, { 8 | "before" : true, 9 | "after" : true 10 | }] 11 | } 12 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | *.txt 19 | 20 | # Directory for instrumented libs generated by jscoverage/JSCover 21 | lib-cov 22 | 23 | .vs 24 | 25 | bin 26 | 27 | notes.md 28 | 29 | obj 30 | 31 | archive 32 | 33 | *.njsproj 34 | *.njsproj.user 35 | *.sln 36 | *.map 37 | *.js 38 | !legacy/*.js 39 | 40 | notes.md 41 | 42 | # Coverage directory used by tools like istanbul 43 | coverage 44 | *.lcov 45 | 46 | # nyc test coverage 47 | .nyc_output 48 | 49 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 50 | .grunt 51 | 52 | # Bower dependency directory (https://bower.io/) 53 | bower_components 54 | 55 | # node-waf configuration 56 | .lock-wscript 57 | 58 | # Compiled binary addons (https://nodejs.org/api/addons.html) 59 | build/Release 60 | 61 | # Dependency directories 62 | node_modules/ 63 | jspm_packages/ 64 | 65 | # TypeScript v1 declaration files 66 | typings/ 67 | 68 | # TypeScript cache 69 | *.tsbuildinfo 70 | 71 | # Optional npm cache directory 72 | .npm 73 | 74 | # Optional eslint cache 75 | .eslintcache 76 | 77 | # Microbundle cache 78 | .rpt2_cache/ 79 | .rts2_cache_cjs/ 80 | .rts2_cache_es/ 81 | .rts2_cache_umd/ 82 | 83 | # Optional REPL history 84 | .node_repl_history 85 | 86 | # Output of 'npm pack' 87 | *.tgz 88 | 89 | # Yarn Integrity file 90 | .yarn-integrity 91 | 92 | # dotenv environment variables file 93 | .env 94 | .env.test 95 | 96 | # parcel-bundler cache (https://parceljs.org/) 97 | .cache 98 | 99 | # next.js build output 100 | .next 101 | 102 | # nuxt.js build output 103 | .nuxt 104 | 105 | # gatsby files 106 | .cache/ 107 | # public 108 | build 109 | 110 | # vuepress build output 111 | .vuepress/dist 112 | 113 | # Serverless directories 114 | .serverless/ 115 | 116 | # FuseBox cache 117 | .fusebox/ 118 | 119 | # DynamoDB Local files 120 | .dynamodb/ 121 | 122 | # TernJS port file 123 | .tern-port 124 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch via NPM", 11 | "runtimeExecutable": "npm", 12 | "runtimeArgs": [ 13 | "run-script", 14 | "debug" 15 | ], 16 | "port": 9227, 17 | "sourceMaps": true 18 | } , 19 | { 20 | "type": "chrome", 21 | "request": "launch", 22 | "name": "Launch Chrome", 23 | "url": "http://localhost:1337", 24 | "webRoot": "${workspaceFolder}" 25 | }, 26 | ], 27 | "compounds": [ 28 | { 29 | "name": "Run and Debug", 30 | "configurations": ["Launch via NPM", "Launch Chrome"] 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | // Note - could the matching of this tsconfig be what is causing .watch tasks to output to the wrong directory? 5 | "version": "2.0.0", 6 | "tasks": [ 7 | { 8 | "type": "typescript", 9 | "tsconfig": "tsconfig.json", 10 | "problemMatcher": [ 11 | "$tsc" 12 | ], 13 | "group": { 14 | "kind": "build", 15 | "isDefault": true 16 | } 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compiling TypeScript 2 | 3 | ## Installing and Running the Completed Package 4 | 5 | 1. OPTIONAL - Install the TypeScript compiler globally (local install is also possible): 6 | `npm install -g typescript` 7 | 8 | 2. Install this package with Git: 9 | `git clone git@github.com:danielstern/compiling-typescript.git` 10 | 11 | 3. Install local packages with `npm`: 12 | `npm install` 13 | 14 | 4. Run TypeScript compilation and start the server simultaneously with: 15 | `npm start` 16 | 17 | ## Exploring the Project 18 | 19 | ### /public 20 | Contains HTML file which is served to the user - aggregates references to generated .js files. 21 | 22 | ### /src 23 | Contains the non-compiled TypeScript code. This code becomes JavaScript that the browser can work with. 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "compiling-type-script2", 3 | "version": "0.0.0", 4 | "description": "CompilingTypeScript2", 5 | "main": "server.js", 6 | "author": { 7 | "name": "Daniel 'Code Whisperer' Stern" 8 | }, 9 | "scripts": { 10 | "build-full": "tsc --build", 11 | "build-server": "tsc -p src/server", 12 | "build-client": "tsc -p src/client", 13 | "watch-client": "tsc -p src/client --watch", 14 | "build": "tsc -p tsconfig.json", 15 | "serve": "node build/server/server.js", 16 | "start": "npm run build-full && npm run serve", 17 | "debug": "node --inspect=9227 build/server/server.js", 18 | "lint": "eslint src/**/*.ts" 19 | }, 20 | "devDependencies": { 21 | "@types/express": "^4.17.1", 22 | "@types/node": "^8.10.58", 23 | "@typescript-eslint/eslint-plugin": "^2.7.0", 24 | "@typescript-eslint/parser": "^2.7.0", 25 | "eslint": "^6.6.0", 26 | "express": "^4.17.1", 27 | "typescript": "^3.2.2" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |