Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno complains about the Dom #6

Closed
JorchRL opened this issue Jun 10, 2022 · 5 comments
Closed

Deno complains about the Dom #6

JorchRL opened this issue Jun 10, 2022 · 5 comments
Labels
bug Something isn't working question Further information is requested

Comments

@JorchRL
Copy link
Owner

JorchRL commented Jun 10, 2022

The compiler will throw errors because there are no HTML elements (obviously) but that is fine. We are not gonna run three.js on Deno itself, but we will use Deno to bundle it, so it has to compile.

I’ll need to research how. I’ve read about using /// <reference lib=“dom” /> but it doesn’t seem to work as expected. Maybe I messed something up 🤔

@JorchRL JorchRL added bug Something isn't working question Further information is requested labels Jun 11, 2022
@JorchRL
Copy link
Owner Author

JorchRL commented Jun 11, 2022

I added /// < reference lib="DOM" /> to the type definitions on commit 5065e16

But I get type definition conflicts between TS's dom and Deno's (ie. those for Deno's global, web, fetch APIs) :(

My guess is to find a way to let the TS compiler know I only want it to use those of the DOM ?

@JorchRL
Copy link
Owner Author

JorchRL commented Jun 11, 2022

From the Deno docs at targeting deno and the browser

"dom" - The main browser global library that ships with TypeScript. The type definitions conflict in many ways with "deno.window" and so if "dom" is used, then consider using just "deno.ns" to expose the Deno specific APIs.

So the way to go seems to be to let TS know that we don't wan to use "deno.window"

Because by default Deno's compiler behaves as if a tsconfig.json file looked like this

{
  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "inlineSourceMap": true,
    "isolatedModules": true,
    "jsx": "react",
    "lib": ["deno.window"],
    "module": "esnext",
    "strict": true,
    "target": "esnext",
    "useDefineForClassFields": true
  }
}

@JorchRL
Copy link
Owner Author

JorchRL commented Jun 11, 2022

I'll try using a deno.json config file with


{
    "compilerOptions": {
        "target": "esnext",
        "lib": [
            "dom",
            "dom.iterable",
            "dom.asynciterable",
            "deno.ns",
            "deno.unstable"
        ]
    }
}

@JorchRL
Copy link
Owner Author

JorchRL commented Jun 11, 2022

It was solved with the solution on the previous comment. On commit 5acbd2e

@JorchRL
Copy link
Owner Author

JorchRL commented Jun 11, 2022

Wait! GitHub closed this automatically from my commit's message! That's cool! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant