Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to replace the typescript alias when compile

I define the typescript alias in tsconfig.json like this:

"paths": {
      "@net/*":["net/*"],
      "@auth/*":["auth/*"],
    },

then using this alias in index.ts like this:

import { ResponseHandler } from "@net/rest/ResponseHandler";
export { ResponseHandler };

when compile the typescript project, I want to replace the alias @net to the project real path like this ../net/rest/ResponseHandler so that the project path could parse correctly when using in other project as a lib. how to replace the alias name? I have tried using tsc-alias by using this command after installed the tsc-alias lib:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"tscbuild": "tsc && tsc-alias",

but it did not replace the @net, what should I do to replace the typescript alias success? any suggestion?

>Solution :

I do not know how to replace the path using tsc-alias. But you can tried to install ttypescript:

yarn add ttypescript --save-dev

and replace your tscbuild command like this:

"tscbuild": "ttsc",

I have tried and it could succesfully replace the path like @net to ../src/net/.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading