Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

440
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda