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

325
Visualizações
How to set up absolute module import to TypeScript?

What is the "best" way to enable absolute import paths, i.e.

import { my_module } from 'src/my_module_file';

There's conflicting information on this; some claiming that this can be achieved with baseUrl and paths settings in tsconfig.json's compilerOptions, and some people claiming the opposite. As a TypeScript newbie, I'm slightly confused.

Do I need to setup Webpack with resolve.modules setting, or is there a feature in TypeScript compiler for converting absolute paths to relative paths during compilation?

Tried this kind of tsconfig.json without luck:

{
    "compilerOptions": {
        "target": "es2017",
        "module": "commonjs",
        "lib": ["es2017"],
        "removeComments": true,
        "sourceMap": true,
        "baseUrl": "./",
        "paths": {
            "*": ["./*"]
        },
        "rootDir": "server",
        "outDir": "generated",
        "typeRoots": ["node_modules/@types"]
    },
    "include": [
        "server/**/*.ts"
    ],
    "exclude": [
        "node_modules"
    ]
}

ps. using Node.js and running my app with ts-node.

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