TypeScript Compiler Options

paths — TypeScript compiler option

Maps import patterns to candidate locations relative to baseUrl if present, otherwise the config file. Does not rewrite emitted specifiers. Configure runtime or bundler separately. Default (5.8.3): unset. Create the labeled files in an isolated local project and run tsc -p tsconfig.json. Expected: no diagnostics; emitted files: none. Local multi-file fixture, not a single-file editor.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "paths": {      "@app/*": [        "./src/*"      ]    }  }}

Parameters & Attributes

NameTypeDescription
pathsspecifier pattern to path array mappingSet in compilerOptions; default: unset.

Working Example

Example Snippettypescript
// File: tsconfig.json (omit this label){  "compilerOptions": {    "target": "ES2022",    "module": "CommonJS",    "strict": true,    "types": [],    "noEmitOnError": true,    "noEmit": true,    "paths": {      "@app/*": [        "./src/*"      ]    }  },  "files": [    "main.ts"  ]}// File: main.tsimport { value } from "@app/value"; console.log(value);// File: src/value.tsexport const value = 7;
TypeScript Reference