ali ghamdan
ali ghamdan•2d ago

Property 'document' does not exist on type 'Window & typeof globalThis'.

actually i know this is normal because its a backend not a frontend, but i'm using linkedom (parse html into DOM) so when i use it, this error occurs, when i run the code it works 100%, but this error from the vscode extension after enabling deno the code:
import { parseHTML } from "linkedom";

const { document } = parseHTML(Deno.readTextFileSync("./MY_FILE.html"));
console.log(document.documentElement.textContent); // works with deno run
import { parseHTML } from "linkedom";

const { document } = parseHTML(Deno.readTextFileSync("./MY_FILE.html"));
console.log(document.documentElement.textContent); // works with deno run
3 Replies
ali ghamdan
ali ghamdanOP•2d ago
fixed: in deno.json i add to the 'lib' array in 'compilerOptions' : "dom"
"compilerOptions": {
"lib": [
"deno.window",
"dom"
]
}
"compilerOptions": {
"lib": [
"deno.window",
"dom"
]
}
Doctor 🤖
Doctor 🤖•2d ago
You should switch deno.window out with deno.ns if you have dom
ali ghamdan
ali ghamdanOP•1h ago
ok, thx

Did you find this page helpful?