tsc – doesn’t compile alias paths

TSC compiler alone can’t resolve the alias paths. So in order to make it work you will be required to install additional dev package

npm install --save-dev tsc-alias

tsc-alias is for replacing alias paths with relative paths after typescript compilation of tsc compiler because the compiler alone can’t resolve the alias paths

After that you need to modify your build command in your package.json file to

"build": "tsc && tsc-alias",

Running npm run build should work after that and the code should be compiled correctly to javascript

If you want to enable also hot reloading you will be required to install one more dev package

npm install --save-dev concurrently

concurrently is for runing multiple commands concurrently

After that you will need to add 1 new script inside your package.json file

"build:watch": "concurrently --kill-others \"tsc -w\" \"tsc-alias -w\"",

Running npm run build:watch should work after that and the code should be compiled correctly to javascript with hot reload functionality

Please Note: I am using this versions of the packages

"tsc-alias": "^1.5.0",
"typescript": "^4.5.5",
"concurrently": "^7.0.0",

Older or newer versions might introduce some issues with compiling the code

Leave a Comment