0Pricing
TypeScript Academy · Lesson

Path mapping & module resolution

Configure path aliases with baseUrl/paths, understand how TS resolves modules, and avoid common pitfalls.

Intro

Goal: Replace long relative imports with path aliases and understand TypeScript`s module resolution rules to keep imports clean.

tsconfig paths

Set baseUrl (project root for non-relative imports) and map aliases in paths. Keys can use * globs.

// file: tsconfig.json (excerpt)
{
  "compilerOptions": {
    "baseUrl": "./src",
			 "paths": {
      "@utils/*": ["utils/*"],
			 "@components/*": ["components/*"]
				 }
  }
}

All lessons in this course

  1. ES Modules (named vs default), re-exports
  2. Ambient declarations (.d.ts) & third-party typings
  3. Path mapping & module resolution
← Back to TypeScript Academy