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

156
Views
How to call an exported typescript function from within javascript

I have a typescript file with imports eg:

util.ts file

import { protractor } from 'protractor'

export const waitForFile = async () => {
 protractor.promise....
 return await ''
}

Now helper.js file

const getUtilFunction = (func) => {
  const { register } = require('ts-node');
  const { compilerOptions } = require('./tsconfig.json');
  register({ compilerOptions });
  const result = require('./utils.ts');
  return result[func];
};

const waitTillReportGenerated = async () => {
  const waitForFileToDownload = getUtilFunction('waitForFileToDownload');
  const file = await waitForFileToDownload('./result/result.js', 60000);
  console.log(file);
}

However when we call the helper.js function it throws error that protractor is undefined. Can someone please help me with this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to convert .ts file to .js.

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!