Skip to content
Free since 2015. Built for the engineers who keep things running.

cat /articles/how-to-set-an-absolute-path-in-typescript.md

Platform Engineering

How to set an absolute path in TypeScript

Absolute file paths can help organize the imports in your TypeScript projects by improving the way import locations are fetched by the compiler. When a project grows bigger, your library of modules grows. The modules in your project might be referencing each other via imports.

Towards the Cloud13 Oct 2022 · summary

article --summary

The summary

Absolute file paths can help organize the imports in your TypeScript projects by improving the way import locations are fetched by the compiler. This can become quite complex to manage when you have to import modules from their relative path in which the code is executed. An absolute path in TypeScript is the full path starting from the root of the operating file system up until the working directory. If you want to make use of absolute file paths in your TypeScript app then you need to update the tsconfig.json file which you can find at the root of your TypeScript project. As you can see configuring TypeScript with a baseUrl and paths in the tsconfig.json of your TypeScript compiler options can simplify the way you import modules without using relative paths.

Editorial note: This is a summary of an article first published by Towards the Cloud. The full piece is on their site.

articles --latest

Latest articles

New from the blogs we follow and the community.

All articles

newsletter --weekly

DevOps Weekly, minus the noise.

The best reads, new jobs and upcoming events, in one email a week.