Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

334
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda