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

310
Visualizações
TypeScript relative path does not resolve to index file

I'm working on a project and I set up absolute path imports in my project. But, it doesn't resolve to the index file if I put only up to the folder name.

src
 |--modules
      |--search
           |--utils.ts
           |--index.ts

When I import, import { something } from 'modules/search/index' it works fine.

But, I when I import like import { something } from 'modules/search' It says, src/modules/search.ts not found.

Following is my tsconfig.json.

{
  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "strict": true,
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2017", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": "src",
  },
  "exclude": ["node_modules", "tmp"]
}

How can I solve this problem?

The expected behavior is, import { something } from 'modules/search' should resolve to src/modules/search/index.ts

import { something } from 'modules/search/utils' should resolve to src/modules/search/utils.ts

about 4 years ago · Juan Pablo Isaza
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