Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!