[node] Update typings to v22.4.0#70262
Conversation
81bd09b to
d69dcb6
Compare
https://github.com/nodejs/node/releases/tag/v22.4.0 - deps,lib,src: add experimental web storage - doc: doc-only deprecate OpenSSL engine-based APIs - util: support --no- for argument with boolean type for parseArgs
d69dcb6 to
1b6295c
Compare
|
@Semigradsky Thank you for submitting this PR! This is a live comment that I will keep updated. 1 package in this PRCode ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 70262,
"author": "Semigradsky",
"headCommitOid": "1b6295c63babc5496d3f06584b756f900570f518",
"mergeBaseOid": "eaedfc05e7edfd29de7be492d527d8bcfd691a88",
"lastPushDate": "2024-08-10T11:54:53.000Z",
"lastActivityDate": "2024-08-16T18:06:48.000Z",
"mergeOfferDate": "2024-08-16T16:50:14.000Z",
"mergeRequestDate": "2024-08-16T18:06:48.000Z",
"mergeRequestUser": "Semigradsky",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "node",
"kind": "edit",
"files": [
{
"path": "types/node/globals.d.ts",
"kind": "definition"
},
{
"path": "types/node/package.json",
"kind": "package-meta-ok"
},
{
"path": "types/node/test/util.ts",
"kind": "test"
},
{
"path": "types/node/tls.d.ts",
"kind": "definition"
},
{
"path": "types/node/util.d.ts",
"kind": "definition"
}
],
"owners": [
"Microsoft",
"jkomyno",
"alvis",
"r3nya",
"btoueg",
"smac89",
"touffy",
"DeividasBakanas",
"eyqs",
"Hannes-Magnusson-CK",
"hoo29",
"kjin",
"ajafff",
"islishude",
"mwiktorczyk",
"mohsen1",
"galkin",
"parambirs",
"eps1lon",
"ThomasdenH",
"WilcoBakker",
"wwwy3y3",
"samuela",
"kuehlein",
"bhongy",
"chyzwar",
"trivikr",
"yoursunny",
"qwelias",
"ExE-Boss",
"peterblazejewicz",
"addaleax",
"victorperin",
"ZYSzys",
"NodeJS",
"LinusU",
"wafuwafu13",
"mcollina",
"Semigradsky"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2024-08-16T16:35:41.000Z",
"isMaintainer": true
}
],
"mainBotCommentID": 2288184805,
"ciResult": "pass"
} |
|
🔔 @microsoft @jkomyno @alvis @r3nya @btoueg @smac89 @Touffy @DeividasBakanas @eyqs @Hannes-Magnusson-CK @hoo29 @kjin @ajafff @islishude @mwiktorczyk @mohsen1 @galkin @parambirs @eps1lon @ThomasdenH @WilcoBakker @wwwy3y3 @samuela @kuehlein @bhongy @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @ZYSzys @nodejs @LinusU @wafuwafu13 @mcollina — please review this PR in the next few days. Be sure to explicitly select |
|
@Semigradsky The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds that are failing do not end up on the list of PRs for the DT maintainers to review. |
| /** | ||
| * A browser-compatible implementation of [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). | ||
| * Data is stored unencrypted in the file specified by the `--localstorage-file` CLI flag. | ||
| * Any modification of this data outside of the Web Storage API is not supported. | ||
| * Enable this API with the `--experimental-webstorage` CLI flag. | ||
| * @since v22.4.0 | ||
| */ | ||
| var localStorage: Storage; | ||
|
|
||
| /** | ||
| * A browser-compatible implementation of [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage). | ||
| * Data is stored in memory, with a storage quota of 10 MB. | ||
| * Any modification of this data outside of the Web Storage API is not supported. | ||
| * Enable this API with the `--experimental-webstorage` CLI flag. | ||
| * @since v22.4.0 | ||
| */ | ||
| var sessionStorage: Storage; |
There was a problem hiding this comment.
Should these use the DOM types if available?
There was a problem hiding this comment.
Storage is interface, it extends existing DOM type if available.
|
@jakebailey could you please take a look? |
|
Ready to merge |
| * Enable this API with the `--experimental-webstorage` CLI flag. | ||
| * @since v22.4.0 | ||
| */ | ||
| var localStorage: Storage; |
There was a problem hiding this comment.
@Semigradsky what are you thoughts about this suggested change?
Since these globals are only available at runtime when the --experimental-webstorage is passed, I'd say it's confusing to provide them without needing runtime checks.
| var localStorage: Storage; | |
| var localStorage: Storage | undefined; |
There was a problem hiding this comment.
The convention within @types/node (mostly) is not to type features that live behind flags as possibly undefined.
Not only does this force type checking/assertions on projects that know their own build environment, but for global variables, it's just incorrect: it's not the case that the variable is potentially undefined, it's that it potentially doesn't exist, and those are not equivalent.
declare var localStorage: Storage | undefined;
// TypeScript tells me I should check that this isn't undefined...
if (localStorage) {
localStorage.clear();
}The TypeScript compiler is perfectly happy here, which makes it a rather jarring experience when you run this and encounter Uncaught ReferenceError: localStorage is not defined.
There was a problem hiding this comment.
Ophf 🤔 You're right. That case is not covered. I wondered if using never would be better, but it doesn't seem to be the case.
At the very least, this could have an experimental tag? Not that I'd expect great IDE support for highlighting that 😔
There was a problem hiding this comment.
One thing to note is that you still need to end up in a position where loading the Node types and the DOM types together doesn't fall over; DT should be testing that already, and I would suspect that adding | undefined would probably cause errors.
There was a problem hiding this comment.
Another alternative to keep things sane around types for experimental features would be to separate these experimental types into a separate file, such that users can opt into the feature via a simple top-level import:
import type "node/experimental-webstorage";Is that something which has been discussed already?
There was a problem hiding this comment.
I don't think it's a good idea to introduce imports which would crash at runtime; there's no way to enforce that an import is only used as a type import.
IMO this seems like a lot of work for not too much benefit; I'll note that the DOM types have some cases like this already for features that are only enabled in secure contexts, and those aren't even experimental.
There was a problem hiding this comment.
I don't think it's a good idea to introduce imports which would crash at runtime;
I agree and that's the point of my initial comment. In its current form the localStorage is declared while most likely not even defined, resulting in the Uncaught ReferenceError: localStorage is not defined for the average user, as @Renegade334 mentioned above. Putting this in a separate file, users would at least have to opt-into getting these experimental types declared on the global namespace.
https://github.com/nodejs/node/releases/tag/v22.4.0
Fix #70056