dan.the.discloser
dan.the.discloser•2y ago

where does `document` come from

the default ultra gives me a client.tsx like this
import hydrate from "ultra/hydrate.js";
import App from "./src/app.tsx";
hydrate(document, <App />);
import hydrate from "ultra/hydrate.js";
import App from "./src/app.tsx";
hydrate(document, <App />);
when I run deno check it complains about document how / where it getting document from?
9 Replies
dan.the.discloser
dan.the.discloser•2y ago
i presume I need a compiler option for the checker?
Antonio Sampaio
Antonio Sampaio•2y ago
maybe: lib: ['dom'] ?
Doctor 🤖
Doctor 🤖•2y ago
From my understanding document doesn't exist in the Deno environment, only the web environment. the lib: ['dom'] allows you to use the types in Deno for TypeScript. You can make your own document by importing a DOMParser module to create a blank document and assigning it globally.
globalThis.document = new DOMParser().parseFromString('<!DOCTYPE html><html><head></head><body></body></html>', 'html/text')
globalThis.document = new DOMParser().parseFromString('<!DOCTYPE html><html><head></head><body></body></html>', 'html/text')
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Doctor 🤖
Doctor 🤖•2y ago
Well you shouldn't make your own document for the web browser, but if you want those createElement stuff for deno side then that is an option.
dan.the.discloser
dan.the.discloser•2y ago
the lib: ['dom'] doesn't fix it for me. i will try the /// <reference lib="dom" /> and report back
Doctor 🤖
Doctor 🤖•2y ago
The lib: ['dom'] only adds the typings so it can be transpiled to javascript.
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
dan.the.discloser
dan.the.discloser•2y ago
the /// <reference lib="dom" /> makes deno lint happy but not deno check