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

335
Visualizações
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 à 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