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

Add @types/deno #70492

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

dsherret
Copy link
Contributor

@dsherret dsherret commented Sep 9, 2024

Adds @types/deno. This was previously done in #60557, but closed because at the time we didn't believe there was much use for it. Nowadays with Deno 2.0, it will be possible to use Deno without the Deno language server when only using npm packages via a package.json and so it might be useful to have types for deno available at @types/deno.

The types here are code generated by denoland/deno#25545

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an npm package, match the name. If not, do not conflict with the name of an npm package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • Represents shape of module/library correctly
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

@typescript-bot
Copy link
Contributor

typescript-bot commented Sep 9, 2024

@dsherret Thank you for submitting this PR!

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

This PR adds a new definition, so it needs to be reviewed by a DT maintainer before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 Only a DT maintainer can approve changes when there are new packages added

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.

Inactive

This PR has been inactive for 9 days.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 70492,
  "author": "dsherret",
  "headCommitOid": "53c816747eaefba0c565d10858587aed59ebbac1",
  "mergeBaseOid": "5f56dc762773f1213fda4248e37a261637527c33",
  "lastPushDate": "2024-09-09T23:33:23.000Z",
  "lastActivityDate": "2024-09-16T20:15:53.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": true,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "deno",
      "kind": "add",
      "files": [
        {
          "path": "types/deno/.eslintrc.json",
          "kind": "package-meta",
          "suspect": "edited"
        },
        {
          "path": "types/deno/.npmignore",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/deno/deno-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/deno/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/deno/package.json",
          "kind": "package-meta-ok"
        },
        {
          "path": "types/deno/tsconfig.json",
          "kind": "package-meta",
          "suspect": "not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-tsconfigjson) (check: `compilerOptions.lib.0`)"
        }
      ],
      "owners": [],
      "addedOwners": [
        "dsherret",
        "bartlomieju"
      ],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "stale",
      "reviewer": "jakebailey",
      "date": "2024-09-14T17:29:46.000Z",
      "abbrOid": "53a9958"
    },
    {
      "type": "stale",
      "reviewer": "lucacasonato",
      "date": "2024-09-12T17:07:21.000Z",
      "abbrOid": "53a9958"
    }
  ],
  "mainBotCommentID": 2339330236,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added New Definition This PR creates a new definition package. Check Config Changes a module config files Huge Change labels Sep 9, 2024
@typescript-bot
Copy link
Contributor

🔔 @dsherret — you're the only owner, but it would still be good if you find someone to review this PR in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)

@jakebailey
Copy link
Member

Any reason to put all of the types here versus publishing a package which is referenced here? It seems like this is all ambient. Up to you.

@dsherret
Copy link
Contributor Author

@jakebailey what's the advantage of doing that?

@jakebailey
Copy link
Member

It's just so that you can avoid having to push code here all the time; @types/bun is that way, though you still have to bump here to bump versions, so it's a little moot (and having the code/tests here means we'll actually be able to track them and check for compat, keep them tidy).

@typescript-bot
Copy link
Contributor

@jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@dsherret
Copy link
Contributor Author

It's just so that you can avoid having to push code here all the time; @types/bun is that way, though you still have to bump here to bump versions, so it's a little moot (and having the code/tests here means we'll actually be able to track them and check for compat, keep them tidy).

Yeah, I feel like that creates a bit of indirection and as you said this already requires a review. It is nice to get the tooling here. We do have https://www.npmjs.com/package/@deno/types that we published to once for a single user and I was planning on deprecating it after this.

Side note: I'm actually surprised @types/* allows dependencies outside of that scope. Seems less safe... I always thought of the @types/ scope being hard to get a vulnerability into because of all the linting/reviews here.

@jakebailey
Copy link
Member

Dependencies are manually reviewed and put in a list on dt-tools, so it's not just anything.

types/deno/package.json Outdated Show resolved Hide resolved
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

Marking as needs review for the version thing; the suffix will definitely not behave the way you'd think and it's a bug that the tests don't complain.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Sep 10, 2024
@typescript-bot
Copy link
Contributor

@dsherret One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Sep 10, 2024
@typescript-bot
Copy link
Contributor

@jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@dsherret
Copy link
Contributor Author

dsherret commented Sep 12, 2024

Dependencies are manually reviewed and put in a list on dt-tools, so it's not just anything.

Personally it still seems concerning to me because there are dependencies of packages in @types using ~ version constraints. I kind of feel like it shouldn't be allowed.

@jakebailey
Copy link
Member

Personally it still seems concerning to me because there are dependencies of packages in @types using ~ version constraints. I kind of feel like it shouldn't be allowed.

The key factor is that we really only add deps which are also deps of the packages being typed, such that some sort of transitive compromise is no worse than if you hadn't installed the types at all.

* was not found.
*
* @category Errors */
export class NotFound extends Error {}
Copy link
Member

Choose a reason for hiding this comment

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

All of these error types are empty classes so are treated as the same type as Error (same structure, same type, not nominal); is there some private prop/identifier that can be added to these to distinguish them, or is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

instanceof Deno.errors.NotFound

Copy link
Member

Choose a reason for hiding this comment

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

*
* @default {false}
*/
env?: "inherit" | boolean | string[];
Copy link
Member

Choose a reason for hiding this comment

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

In general I would double check that you don't want env?: "inherit" | boolean | string[] | undefined, for people using exactOptionalPropertyTypes, especially on options bags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think maybe adding it would add some confusion around what env: undefined means. Generally people would just provide the properties they want to change here.

@@ -0,0 +1,9756 @@
// Copyright 2018-2024 the Deno authors. MIT license.

/// <reference lib="dom" />
Copy link
Member

Choose a reason for hiding this comment

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

What from the DOM is needed here? Usually requiring this isn't a good idea, rather, we can design packages to work with or without these and then have the DT infra test with multiple configurations (new to DT)

Choose a reason for hiding this comment

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

I think Request, Response, and URL - but probably we shouldn't do this here I agree.

Copy link
Contributor Author

@dsherret dsherret Sep 14, 2024

Choose a reason for hiding this comment

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

Yeah, I shouldn't have added it. Tests seem to pass now without it though. Edit: Follow up here: #70492 (comment) (it's because of the tsconfig)

Comment on lines +3557 to +3558
| "SIGXCPU"
| "SIGXFSZ";
Copy link
Member

Choose a reason for hiding this comment

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

One day I'll find the time to get dprint to write:

| "foo"
| "bar"
;

@typescript-bot
Copy link
Contributor

@lucacasonato, @jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

"strictFunctionTypes": true,
"types": [],
"lib": [
"DOM",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, because I had it here. I'll look into removing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, removing this requires a pretty significant change. Might be better to just require people to use "DOM" for now, then we can look into creating all the conditional types later so it works well with or without dom types.

@typescript-bot
Copy link
Contributor

@jakebailey, @lucacasonato Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@jakebailey
Copy link
Member

Are you expecting to have this out before Deno v2, or should this be waiting until then?

@dsherret
Copy link
Contributor Author

It would be nice to land this before and then we can iterate on it. It's a brand new distribution form so probably not a bad thing to release it early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Check Config Changes a module config files Huge Change New Definition This PR creates a new definition package.
Projects
Status: Needs Maintainer Action
Development

Successfully merging this pull request may close these issues.

4 participants