There seems to be a type inference issue with TypeScript in the if condition involving the 'title' variable
The inferred type of the variable title
that is being passed to the trim
method is never
let title: string | null = null;
const response = await fetch("https://example.com");
const newResponse = await new HTMLRewriter()
.on("#title", {
text({ text }) {
title ??= "";
title += text;
},
})
.transform(response);
await newResponse.arrayBuffer();
if (title !== null) {
title = title.trim();
}
export {};