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

332
Views
Converting $$eval extraction method from JS to TS

I am begginer to both Typescript and Javascript. I was recently reading the below JS code:

var Elements =  await this.page.$$eval(`div[data-testid="board-list:${board}"]`, elements => elements.map(el => el.innerText.trim().split('\n')));

This extracts a couple of "board" elements by using method "elementHandle.$$eval(selector, pageFunction[, arg])" . Please find documentation for it here: https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector-all

I tried translating this into Typescript however I am not sure how to define board as I get syntax error: "Variable 'board' is used before being assigned"

I tried the following TS code:

let board: string;
const Elements = await this.page.$$eval(
  `div[data-testid="board-list:${board}"]`,
  (elements: HTMLElement[]) =>
    elements.map((el: HTMLElement) => (el as HTMLElement).innerText.trim().split('\n')),
);

Would you please help me understand how I could translate the "board" variable into a Typescript style of code? There may be a simple solution which I am not aware about

about 4 years ago · Juan Pablo Isaza
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!