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

Should "dom" lib be added to the default tsonfig? #3799

Closed
Dan503 opened this issue Jan 26, 2020 · 12 comments
Closed

Should "dom" lib be added to the default tsonfig? #3799

Dan503 opened this issue Jan 26, 2020 · 12 comments

Comments

@Dan503
Copy link

Dan503 commented Jan 26, 2020

After watching some conference talks on YouTube I thought I would try giving it a go.

I ran into this issue though when playing around with it:
#3793 (comment)

One of the core tenants of Deno is that Deno should be browser compatible:
https://youtu.be/z6JRlx5NC9E (11:55)

Currently by default the tsconfig will cause errors to be thrown if you use variables like document and window.

If being browser compatible is one of Deno's core tenants though, shouldn't it have the "dom" lib active in it's default tsconfig?

@ry
Copy link
Member

ry commented Jan 26, 2020

Yea makes sense to me.

@nayeemrmn
Copy link
Collaborator

This is the reverse of what we mean by browser compatibility. Deno doesn't have a document and it compiles stuff it's supposed to be able to run.

Maybe you just meant the tsconfig used for deno bundle? See #3793 (comment).

@Dan503
Copy link
Author

Dan503 commented Jan 26, 2020

Maybe you just meant the tsconfig used for deno bundle?

That was what essentially inspired this issue. If I run deno bundle I believe it should be able bundle browser based code.

@Dan503
Copy link
Author

Dan503 commented Jan 26, 2020

If I use the Deno.bundle() API in a file that is run using deno run then that should be able to understand browser based code as well by default.

@Pandawan
Copy link

As a temporary fix, I found that appending this at the top of the file works (though VSCode/non-deno-typescript will throw errors).

/// <reference lib="https://raw.githubusercontent.com/microsoft/TypeScript/master/lib/lib.dom.d.ts" />

@kitsonk
Copy link
Contributor

kitsonk commented Jan 27, 2020

@ry, no I would rather deliver #3726 and only have these apply to the runtime compiler APIs... Allowing other libs through that Deno doesn't support itself and typechecking against it erodes the value of TypeScript build into Deno IMO.

@ry
Copy link
Member

ry commented Jan 27, 2020

@kitsonk You make a good point that Deno shouldn't accept code that it can't run. I retract my "makes sense" comment above. I think we all agree that we need to make a non-buggy workflow for users to have DOM APIs in their isomorphic apps.

@pandawanfr I actually think that solution is pretty cool....

@Dan503
Copy link
Author

Dan503 commented Jan 27, 2020

Ok so the answer to the question is:

No, Deno doesn't have a DOM so the DOM lib shouldn't be applied by default.

@kitsonk
Copy link
Contributor

kitsonk commented Jan 27, 2020

@Dan503, yes, but we should have a way to support including it in some fashion. As mentioned in #3726, I am starting working on a solution.

@Dan503
Copy link
Author

Dan503 commented Jan 27, 2020

So does that mean this issue should be reopened?

@kitsonk
Copy link
Contributor

kitsonk commented Jan 27, 2020

No, as we don't want it to be defaulted to be on. Closing #3726 should meet everyones use case in a way that is supportable the long term.

@jimboyeah
Copy link

As a temporary fix, I found that appending this at the top of the file works (though VSCode/non-deno-typescript will throw errors).

/// <reference lib="https://raw.githubusercontent.com/microsoft/TypeScript/master/lib/lib.dom.d.ts" />

if that works, and also done this

https://raw.githubusercontent.com/denoland/deno/main/cli/dts/lib.dom.d.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants