# tsc-alias Replace alias paths with relative paths after typescript compilation. You can add aliases that reference other projects outside your tsconfig.json project by providing a relative path to the baseUrl. [](https://badge.fury.io/js/tsc-alias) [](http://doge.mit-license.org) [](https://www.paypal.com/donate/?hosted_button_id=FPRE4VERGHZ3E) ## Comparison to [tsconfig-paths](https://github.com/dividab/tsconfig-paths) \+ Compile time (no runtime dependencies) ## Getting Started First, install tsc-alias as devDependency using npm. ```sh npm install -g tsc-alias ``` ``` npm install --save-dev tsc-alias ``` ## Add it to your build scripts in package.json ```json "scripts": { "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json", } ``` or ```json "scripts": { "build": "tsc && tsc-alias", "build:watch": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")" } ``` ## Issues If you have an issue, please create one. But, before: - try to check the [FAQ.](https://github.com/justkey007/tsc-alias/discussions/110) - try to check if there exits alike issues. - try to run with `--debug` and check if config is correctly loaded and all sourcefiles are found. ## API ### Installation ```sh npm install tsc-alias ``` ### Usage ```typescript import { replaceTscAliasPaths } from 'tsc-alias'; replaceTscAliasPaths(options?); ``` Here are all the available options:
| Option | Description | Default Value |
|---|---|---|
| project, p | path to tsconfig.json | 'tsconfig.json' |
| watch | Observe file changes | false |
| outDir | Run in a folder leaving the "outDir" of the tsconfig.json (relative path to tsconfig) | tsconfig.compilerOptions.outDir |
| declarationDir | Works the same as outDir but for declarationDir | tsconfig.compilerOptions.declarationDir |
| resolveFullPaths | Attempt to replace incomplete import paths (those not ending in .js) with fully resolved paths (for ECMAScript Modules compatibility) |
false |
| resolveFullExtension | Allows you to specify the extension of incomplete import paths, works with resolveFullPaths |
'.js' | '.mjs' | '.cjs' |
| silent | Reduced terminal output. This is a deprecated option and no longer has any effect. | true |
| verbose | Additional information is output to the terminal | false |
| debug | Debug information is send to the terminal | false |
| replacers | Files to import as extra replacers More info | [] |
| output | The output object tsc-alias will send logs to. | new Output(options.verbose) |
| fileExtensions | Overwrite file extensions tsc-alias will use to scan and resolve files. | undefined |