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

Update @types/node dependency version #13987

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vitch
Copy link
Contributor

@vitch vitch commented Sep 16, 2024

When I upgraded my project to use [email protected] I ran into the issue described in this SO post.

The solution is to use a newer version of @types/node which has been updated to deal with the changes in the latest TypeScript.

In my project I've introduced an explicit dependency on @types/[email protected] (the newest version currently available in the ^20.0.0 range) since the fix doesn't exist in 20.12.14 (the newest version available in the ~20.12.8 range which was currently defined) which seems to solve the problem. But I thought it would be helpful to others if the change was made here so they didn't need to debug the problem.

DISCLAIMER: I don't know how these types are used and if there is any chance I've introduced other problems with this change...

What does this PR do?

Updates the @types/node dependency in bun-types from ~20.12.8 to ~20.16.5

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

@vitch
Copy link
Contributor Author

vitch commented Sep 16, 2024

I was a little surprised that these were the changes in the lockfile included in this PR:

Screenshot 2024-09-16 at 16 34 37

I'm not sure why @types/node@* wasn't also updated from 20.12.14?

@@ -14,7 +14,7 @@
],
"homepage": "https://bun.sh",
"dependencies": {
"@types/node": "~20.12.8",
"@types/node": "~20.16.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

The 22.x branch is a closer match to Bun, so is there a reason to not adopt that?

Suggested change
"@types/node": "~20.16.5",
"@types/node": "~22.5.5",

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 was being conservative because I wasn't really sure how the version was chosen or if bun was aiming for compatibility with a particular version of node.
The version was last updated in 2a40148 and I didn't see why that specific version was chosen (I don't think it was the latest on May 1st?). A specific version of @types/node (rather than *) was added in #8195 but looking through that I didn't see any reasoning behind how the version was chosen.
TL;DR - I'm happy to make this change (and the corresponding change in the lockfile) but would love to understand the more about the why of this version!

Copy link
Contributor

Choose a reason for hiding this comment

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

Very reasonable. I'm curious as well. Thanks for pushing this along!

@Jarred-Sumner
Copy link
Collaborator

Thanks for this.

We probably should update it to match the current reported version of Node, which I think is the very latest release

@vitch
Copy link
Contributor Author

vitch commented Sep 17, 2024

Thanks for this.

We probably should update it to match the current reported version of Node, which I think is the very latest release

No worries :)

the current reported version of Node

Sorry for being dense but not sure what you mean here... This page "reflects Bun's compatibility with Node.js v20".

The node website offers v20.17.0 as LTS or v22.8.0 as current:
Screenshot 2024-09-17 at 11 09 56

@vitch
Copy link
Contributor Author

vitch commented Sep 17, 2024

the current reported version of Node

Ah - I poked around a bit more and saw that process.version is probably what you're talking about.

I'm using [email protected] and process.version returns v22.6.0. There is no 22.6.x released for @types/node so I'll update to the latest available (22.5.5)...

When I upgraded my project to use [email protected] I ran into the issue
described in [this SO post](https://stackoverflow.com/a/78790944/223931).

The solution is to use a newer version of `@types/node` which has been
updated to deal with the changes in the latest TypeScript.

In my project I've introduced an explicit dependency on `@types/[email protected]`
(the newest version currently available in the `^20.0.0` range) since the
fix doesn't exist in `20.12.14` (the newest version available in the `~20.12.8`
range which was currently defined) which seems to solve the problem. But I
thought it would be helpful to others if the change was made here so they
didn't need to debug the problem.

DISCLAIMER: I don't know how these types are used and if there is any chance
I've introduced other problems with this change...
This is the closest available match to the version reported by
`process.version` in the current version of `bun`
@vitch
Copy link
Contributor Author

vitch commented Sep 17, 2024

I'm still a little confused by the lockfile changes:

Screenshot 2024-09-17 at 11 27 29

I would expect @types/node@* to have been also pointed at the new version since it's in range? I tried with bun update as well as by manually editing the package.json and running bun install but the effect was the same?

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.

3 participants