0

So I asked this question earlier today on how to use paths.

Now I'm trying to convert this project using that approach.

So I first clone it:

git clone git@github.com:fireflysemantics/validator.git

Then edit the paths setting so it looks like this:

"baseUrl": "./",                          /* Base directory to resolve non-absolute module names. */
"paths": {
  "@fs": ["./src"], 
  "@test": ["./test"]
},                                        /* 

Then I tried editing the src/container/error/index.ts so that it looks like this:

export { ObjectErrors } from "@fs/container/error/ObjectErrors";
export { ValidationError } from "./ValidationError";

When I compile Typescript still generates this error:

src/container/error/index.ts:1:30 - error TS2307: Cannot find module '@fs/container/error/ObjectErrors'.

1 export { ObjectErrors } from "@fs/container/error/ObjectErrors"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thoughts?

Typescript Github Issue

Filed an Issue with Typescript here

Ole
  • 41,793
  • 59
  • 191
  • 359

1 Answers1

-1

Add your paths property to the compilerOptions in the tsconfig file.

  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "paths": {      
      "@app/*": [
        "./app/*"
      ]
    }
  }
}
  • Just double checked - AFAIK it's in the `compilerOptions` section ...? – Ole Mar 27 '19 at 22:45
  • Did you not look at the sample config object?, it is in the compilerOptions section – webpopular.net Mar 28 '19 at 18:34
  • [This is the config I'm converting](https://github.com/fireflysemantics/validator/blob/master/tsconfig.json). I first created a minimal MVCE in order to make sure I had something that works. Now I'm trying to apply that to a different project, and it's not working ... – Ole Mar 28 '19 at 18:42
  • Did you try cloning the project to see if it works on your end? You'll notice in the previous answer that I linked that we had to remove the glob patterns to get it to work. – Ole Mar 28 '19 at 18:43