typescript-paths
v1.5.1
Published
Resolving tsconfig paths in runtime
Downloads
62,458
Readme
typescript-paths
Resolving tsconfig paths in runtime
npm install typescript-paths
const { register } = require("typescript-paths")
register()
Example tsconfig.json
{
"compilerOptions": {
"paths": {
"~/*": ["./*"]
}
}
}
Then you can import alias instead of annoying path
// const App = require("../../../../App")
const App = require("~/App")
Options
tsConfigPath (string | string[])
Specify the path where your TypeScript configuration file.
If not set:
- use Environment variable TS_NODE_PROJECT
- or search tsconfig.json in current working directory.
logLevel ("none" | "error" | "warn" | "info" | "debug" | "trace") (default: "info")
Set the logging level on the plugin.
fallback (function (string): string | undefined)
The handler to handle unusual module name.
color (boolean) (default: true)
Colorful ouput.
respectCoreModule (boolean) (default: true)
reference
- https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
- https://github.com/microsoft/TypeScript/issues/5039