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

163
Visualizações
how to prevent typescript from adding imports in compiled files

I'm building an electron js app with some js libraries like prismjs.

I tried adding @types/prismjs to my node modules and many other ways

but still typescript tries to import it import {something} from "prismjs" (in generated js file which I don't want it)

I have seen similar questions in stack overflow but none of them solved my issue.

app/ts config

{
    "compilerOptions": {
        "module": "ES2020",
        "target": "ES2021",
        "noImplicitAny": true,
        "removeComments": true,
        "allowUnreachableCode": false,
        "strictNullChecks": true,
        "strict": true,
        "noImplicitUseStrict": false,
        "alwaysStrict": true,
        "allowSyntheticDefaultImports": true,
        "typeRoots": ["../node_modules/@types"],
        "sourceMap": true
    }
}

app/script.ts

import { highlightElement } from "prismjs";

window.addEventListener("keyup", ev => {
    if (ev.key === "F5") window.location.reload();
});

const el = document.querySelectorAll("code")[1];
el.onkeyup = () => {
    highlightElement(el);
};

project structure enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

However... After hours of researching I finally found a way to solve this question. thanks to this answer https://stackoverflow.com/a/55377372/16906284

adding the two lines below in tsconfig.json would solve that problem...

{
    ...
    "typeRoots": [ "node_modules/types" ],
    "types": [ "prismjs" ]
}
about 4 years ago · Juan Pablo Isaza Relatório
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