Browse Source

10.5: managing a project with tsconfig.json.

Frederic G. MARAND 5 years ago
parent
commit
e9662cd884
5 changed files with 56 additions and 11 deletions
  1. 2 2
      app/app.ts
  2. 8 8
      app/tsconfig.json
  3. 2 0
      doc/modules.md
  4. 43 0
      doc/options.md
  5. 1 1
      tsconfig.base.json

+ 2 - 2
app/app.ts

@@ -286,12 +286,12 @@ function genericClassDemo() {
   let bookShelf: Shelf<Book> = new Shelf<Book>();
   getBooksInventory().forEach(book => bookShelf.add(book));
   let firstBook: Book = bookShelf.getFirst();
-  // console.log(firstBook);
+  console.log(firstBook);
 
   let magazineShelf: Shelf<Magazine> = new Shelf<Magazine>();
   getMagazinesInventory().forEach(mag => magazineShelf.add(mag));
   let firstMagazine: Magazine = magazineShelf.getFirst();
-  // console.log(firstMagazine);
+  console.log(firstMagazine);
 
   // No longer works after constraining Shelf<T extends ShelfItem>.
   // let numberShelf: Shelf<number> = new Shelf<number>();

+ 8 - 8
app/tsconfig.json

@@ -1,14 +1,14 @@
 {
-  "extends": "../tsconfig.base.json",
+  // Allows inheriting a base configuration.
+  // "extends": "./tsconfig.base.json",
+
   "compilerOptions": {
-    // outFile is not compatible with all module loaders, including CommonJS
     "module": "commonjs",
-    // module: commonjs -> moduleResolution: node, just make it explicit
-    "moduleResolution": "node",
-    // Debug helper
-    // "traceResolution": true,
-    // Paths works with baseUrl to configure how particular modules map to files.
-    "removeComments": true
+    "outDir": "../js",
+    "pretty": true,
+    "removeComments": true,
+    "sourceMap": false,
+    "target": "es5"
   },
   "files": [
     "app.ts"

+ 2 - 0
doc/modules.md

@@ -37,6 +37,8 @@
 Apparemment pas tout à fait correcte: il y a aussi utilisation de 
 `node_modules/@types` pour les imports sans chemin.
 
+https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types
+
 ## "Classic"
 ### "./person" dans /Source/Multimath/player.ts
 

+ 43 - 0
doc/options.md

@@ -0,0 +1,43 @@
+# Compiler options (TypeScript 2.9.2)
+## Major options
+
+Show with `tsc --help` and have a short version.
+
+| Short | Long | Description |
+|-------|------|-------------|
+| -d | --declaration | Generate a `.d.ts` file |
+| -m kind | --module kind | **`none`** `commonjs` `amd` `system` `umd` `es2015` `ESNext` |
+| -p file_or_dir | --project --file_or_dir | Use configuration from the file or the `tsconfig.json` found in the directory |
+| -t VERSION | --target VERSION | **`ES3`** `ES5` `ES2015` `ES2016` `ES2017` `ES2018` `ESNEXT` |
+| -w | --watch | Watch for changed files and compile incrementally |
+
+
+## Normal options 
+
+Show with `tsc --help` but no short version.
+
+| Long | Description |
+|------|-------------|
+| --init | Create a default `tsconfig.json` |
+| --noImplicitAny | Throw on expressions and declarations with an implicit `any` type |
+| --noImplicitReturns | Throw when some code paths do not return a value |
+| --noImplicitThis | Throw on untyped `this` expressions |
+| --outDir dir | Directory in which to output the individual compiled files |
+| --outFile file | File in which to output the aggregated compiled files |
+
+
+## Unlisted options
+
+Shown with `tsc --all` but not `tsc --help``
+
+| Long | Description |
+|------|-------------|
+| --moduleResolution | `node` (like NodeJS with `commonjs` modules), or `classic` (pre-TS1.6) 
+
+## Older options
+
+Documented in 2016 course, but not available in 2.9.2
+
+| Short | Long | Description |
+|-------|------|-------------|
+ |

+ 1 - 1
tsconfig.base.json

@@ -6,7 +6,7 @@
     // "module": "commonjs",
     "sourceMap": true,
     "outDir": "js",
-    // "outFile": "output.js",
+    // "outFile": "js/output.js",
     // "watch": true,
 
     /* Strict Type-Checking Options */