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

158
Visualizações
Pass content of ts variable in js file

I was wondering if it's possible to use the content of a ts variable and use it in js file ? I'm feeling trapped now I realize that I don't know how can I achieve it.

Please send me any suggestion easy to implement if possible.

My ts file with the printedOption that I want to use in my js file. The content of this variable is the value of my select input.

 validateLuggages() {
      this.printedOption = this.selectedOption;
      this.http.get(`/routes/luggages`)
        .subscribe((data) => {
          this.parsedForLuggages = data;
     })
      return this.printedOption;
}

Now, How can I create the instance and use this variable in my JS file ?

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

0

To use any typescript variable inside javascript code you may firstly export the variable in typescript file which you want to use in the js file.

Then, you can simply use the import statement and import the variable from the correct path.

You can check the example below and refer the link for better clarity. LINK

// Add to tsconfig.json:

{ "compilerOptions": { ... "allowJs": true ... } }

import MyModule from './../pages/MyModule';

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