简体   繁体   中英

Trouble converting project to Typescript paths

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

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/*"
      ]
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM