Browse Source

6.6-3: using libs and rootDirs to specify import paths.

Frederic G. MARAND 5 years ago
parent
commit
229a7a5185
3 changed files with 16 additions and 4 deletions
  1. 0 0
      app/person.ts
  2. 1 1
      app/player.ts
  3. 15 3
      app/tsconfig.json

+ 0 - 0
app/modules/person.ts → app/person.ts


+ 1 - 1
app/player.ts

@@ -1,4 +1,4 @@
-import {Person} from "person";
+import {Person} from "./person";
 
 export class Player implements Person {
   age: number;

+ 15 - 3
app/tsconfig.json

@@ -1,14 +1,26 @@
 {
   "extends": "../tsconfig.base.json",
   "compilerOptions": {
-    "removeComments": true,
     // 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
-    "baseUrl": "./modules"
+    // "traceResolution": true,
+    // BaseUrl defines the default search base for non-relative imports
+    "baseUrl": "./modules",
+    // Paths works with baseUrl to configure how particular modules map to files.
+    "paths": {
+      // Module: [paths, relative to baseUrl].
+      "my_lib": ["./customPath"]
+    },
+    // RootDirs is useful when sources to combine are in multiple directory hierarchies.
+    "rootDirs": [
+      "modules",
+      "src",
+      "ts/modules"
+    ],
+    "removeComments": true
   },
   "files": [
     "app.ts"