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