Skip to content

Unable to set global "document" available to imported ts #13715

@cryptographix

Description

@cryptographix

I am setting globalThis.document in my main.ts and expected this to be available to imported modules, but get an error when I execute:

deno run -c tsconfig.json main.ts

error: Uncaught ReferenceError: document is not defined

Is this behaviour correct? Is there another way to inject globals, to implement SSR for example via a simulated DOM?

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2015",
    "lib": [
      "dom",
      "esnext"
    ]
  }
}

main.ts:

globalThis.document = {} as any;
window.document = {} as any;

import {
  attr,
  customElement,
  FASTElement,
  html,
  Observable,
} from "https://cdn.skypack.dev/@microsoft/fast-element?dts";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions