Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Use of alias paths inside a referenced project

Since TypeScript 3, it is possible to use projects as references within a given project.

I was trying to use such feature on two personal projects I have but it was not working. So I decided to use a given example as a starting point: https://github.com/appzuka/project-references-example

When I launch npm run build, all projects compile successfully. I then decided to modify the tsconfig.json file of package animals to include the support of aliases. The file was modified as such:

{
  "extends": "../../tsconfig-base.json",
  "compilerOptions": {
    "outDir": "lib",
    "rootDir": ".",
    "baseUrl": ".",
    "paths": { "@animals/*": [ "*" ] }
  },
  "references": [
    { "path": "../core" }
  ]
}

(baseUrl and paths properties were added inside compilerOptions)

I then modified the first import of dog.tsx file this way:
import { Animal, Size } from @animals/animal;

When I try to build again the main project, it fails. The error is:

ERROR in C:\Users\User\Documents\project-references-example\packages\animals\dog.tsx
[tsl] ERROR in C:\Users\User\Documents\project-references-example\packages\animals\dog.tsx(1,30)
      TS2307: Cannot find module '@animals/animal' or its corresponding type declarations.

To make it working, I need to add the alias also on the main project, like this (in tsconfig.json):

"paths": {
      "@animals/*": [ "packages/animals/*" ]
}

Is there a possibility to use alias in a referenced project without having to specify such alias in the parent project?

Thank you!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!