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

fix(cli): add dom.extras lib #14430

Merged
merged 2 commits into from
Apr 29, 2022
Merged

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Apr 29, 2022

Closes: #12558
Fixes: #14344

This adds the lib.dom.extras.d.ts file and modifies the lib.dom.d.ts file to include it. This solves the problem where users use the lib: ["dom", "deno.ns"] configuration when compiling their isomorphic TypeScript and the distributed version of the DOM library does not include every web standard API that Deno supports, and therefore causes confusing errors to the user.

This means we do make a one line edit to the distributed lib.dom.d.ts to include lib.dom.extras.d.ts. This means that users don't have to explicitly include "dom.extras" when using the library, so for most users previous errors will just "go away".

This does establish a pattern now where we can add items Deno supports in advance of the TypeScript distribution supporting it while allowing more isomorphic code to type check safely.

@kitsonk kitsonk requested a review from dsherret April 29, 2022 03:00
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This will be good to just work now. I think we should consider this same solution for any similar problems (if they exist)

@kitsonk kitsonk merged commit ef26a26 into denoland:main Apr 29, 2022
@kitsonk kitsonk deleted the kitsonk/issue12558 branch April 29, 2022 03:47
cjihrig pushed a commit that referenced this pull request May 5, 2022
@jaydenseric
Copy link

So if you are publishing a .mjs module that has TypeScript JSDoc types, that is intended to work with type safety both in Node.js and Deno TypeScript projects, that uses DOM globals, how are you supposed to support that?

Do you use triple slash references in the published module? If so, what are the right ones to use now? Do you only add this?

/// <reference lib="dom" />

For deno, do you also need to add this:

/// <reference lib="deno.ns" />

If you do, that will break Node.js TypeScript:

Screen Shot 2022-05-09 at 12 05 13 pm

@dsherret
Copy link
Member

dsherret commented May 9, 2022

@jaydenseric would you be able to open a new issue or question on discussions? It’s a better medium than old PRs that are closed.

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

Successfully merging this pull request may close these issues.

AbortSignal.reason not available in lib.dom.d.ts URLPattern not available in lib.dom.d.ts
3 participants