-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
[node] node:module
cleanup
#71303
[node] node:module
cleanup
#71303
Conversation
a168b43
to
0e6854b
Compare
@Renegade334 Thank you for submitting this PR! This is a live comment that I will keep updated. 3 packages 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": 71303,
"author": "Renegade334",
"headCommitOid": "5bd8f0a1a0464e75a3510f2e18e8ad3eb32f274c",
"mergeBaseOid": "5ed1eb15657f15183299a903db34140cb5e9f529",
"lastPushDate": "2024-12-01T01:47:25.000Z",
"lastActivityDate": "2025-01-23T07:13:58.000Z",
"mergeOfferDate": "2025-01-23T01:21:01.000Z",
"mergeRequestDate": "2025-01-23T07:13:58.000Z",
"mergeRequestUser": "Renegade334",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "esm",
"kind": "edit",
"files": [
{
"path": "types/esm/esm-tests.ts",
"kind": "test"
}
],
"owners": [
"Richienb"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
},
{
"name": "httptoolkit__esm",
"kind": "edit",
"files": [
{
"path": "types/httptoolkit__esm/httptoolkit__esm-tests.ts",
"kind": "test"
}
],
"owners": [
"nktnet1",
"pimterry"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
},
{
"name": "node",
"kind": "edit",
"files": [
{
"path": "types/node/globals.d.ts",
"kind": "definition"
},
{
"path": "types/node/module.d.ts",
"kind": "definition"
},
{
"path": "types/node/test/globals.ts",
"kind": "test"
},
{
"path": "types/node/test/module.ts",
"kind": "test"
},
{
"path": "types/node/v18/globals.d.ts",
"kind": "definition"
},
{
"path": "types/node/v18/module.d.ts",
"kind": "definition"
},
{
"path": "types/node/v18/test/globals.ts",
"kind": "test"
},
{
"path": "types/node/v18/test/module.ts",
"kind": "test"
},
{
"path": "types/node/v20/globals.d.ts",
"kind": "definition"
},
{
"path": "types/node/v20/module.d.ts",
"kind": "definition"
},
{
"path": "types/node/v20/test/globals.ts",
"kind": "test"
},
{
"path": "types/node/v20/test/module.ts",
"kind": "test"
}
],
"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",
"NodeJS",
"LinusU",
"wafuwafu13",
"mcollina",
"Semigradsky"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2025-01-23T01:20:00.000Z",
"isMaintainer": true
}
],
"mainBotCommentID": 2509550229,
"ciResult": "pass"
} |
🔔 @Richienb @nktnet1 @pimterry @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 @nodejs @LinusU @wafuwafu13 @mcollina @Semigradsky — please review this PR in the next few days. Be sure to explicitly select |
/* eslint-disable @definitelytyped/no-unnecessary-generics */ | ||
/** | ||
* Register a module that exports hooks that customize Node.js module | ||
* resolution and loading behavior. See | ||
* [Customization hooks](https://nodejs.org/docs/latest-v22.x/api/module.html#customization-hooks). | ||
* @since v20.6.0, v18.19.0 | ||
* @param specifier Customization hooks to be registered; this should be | ||
* the same string that would be passed to `import()`, except that if it is | ||
* relative, it is resolved relative to `parentURL`. | ||
* @param parentURL f you want to resolve `specifier` relative to a base | ||
* URL, such as `import.meta.url`, you can pass that URL here. | ||
*/ | ||
function register<Data = any>( | ||
specifier: string | URL, | ||
parentURL?: string | URL, | ||
options?: RegisterOptions<Data>, | ||
): void; | ||
function register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void; | ||
/* eslint-enable @definitelytyped/no-unnecessary-generics */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a static class method this definition was invisible to @definitelytyped/no-unnecessary-generics, but now pops up on its radar. The signatures themselves have not changed.
This usage verges on "disguised type assertion", but can't be changed without breaking existing usage.
I might be wrong, but isn't NodeRequire pretty commonly used? |
These are the last of the global-scope module types, the others having been removed when the declarations were moved to the |
Re-ping @Richienb, @nktnet1, @pimterry, @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: This PR has been out for over a week, yet I haven't seen any reviews. Could someone please give it some attention? Thanks! |
It has been more than two weeks and this PR still has no reviews. I'll bump it to the DT maintainer queue. Thank you for your patience, @Renegade334. (Ping @Richienb, @nktnet1, @pimterry, @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, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky.) |
@Renegade334 Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day! |
@Renegade334 I haven't seen any activity on this PR in more than three weeks, and it still has problems that prevent it from being merged. The PR will be closed on Jan 8th (in a week) if the issues aren't addressed. |
aa8e7bc
to
3ad5190
Compare
3ad5190
to
d0578d4
Compare
d0578d4
to
35fc681
Compare
@Renegade334 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. |
- findSourceMaps() does not accept an error parameter - constructor options since v20.5 - SourceMap#findEntry() can return an empty object
35fc681
to
32059d8
Compare
@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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there's anything questionable left here, or if you're waiting for some other review, but LGTM
(Just be prepared to need to revert it if something catastrophic happens...) |
Don't believe so. Ready to merge. |
Hello, I believe this PR has introduced an error into our pipeline: node_modules/@types/node/module.d.ts(494,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'. Using
|
Think we are hitting a similar issues with this change:
|
Pin @types/node due to DefinitelyTyped/DefinitelyTyped#71303 (comment)
Yeah, this is the kind of thing I was worried about when I was talking about It's not clear to me why this didn't fail CI, given |
Actually, this is puzzling; the definition of interface NodeRequire extends NodeJS.Require {}
declare var require: NodeRequire; I have no idea why this would fail to work. |
I guess we could also update webpack-env to say |
Made the edit manually and build passed :) |
The commit above from ni/nimble@46a55c9 says TS 5.4, though I don't know how to verify that is what actually ran and failed. https://github.com/search?q=repo%3Ani%2Fnimble%20%2F%22typescript%22%2F&type=code seems to imply so. |
So, the root cause actually appears to be a compiler quirk (bug?) relating to duplicate inheritance from an interface with one or more callable signatures. The issue is that there ends up being two duplicate A minimal example: interface A { (): void }
interface B extends A {}
interface B extends A {}
declare var a: A;
declare var a: B; The shape of It looks like parcel-env and webpack-env have interface declarations for |
Was found to be structurally quite messy during recent definition updates. This changeset performs the following:
module
,require
) and NodeJS-namespaced interfaces (eg.NodeJS.Module
) into module.d.ts, which is in keeping with the paradigm of modules defining related globals where possible (eg. url, stream/web, etc.)NodeModule
andNodeRequire
aliases, which were used prior to @types/node v13; the modern equivalent is to use the the namespacedNodeJS.Module
etc.$ExpectType
changes, but is otherwise a fully transparent change.Module
namespace. Top-levelnode:module
exports were previously haphazardly defined as either namespaced declarations or static elements on theModule
class; this change doesn't affect the behaviour of any imports fromnode:module
, but does improve readability and maintainability.NodeJS.Module
:module.require
is a simple function, rather than aNodeJS.Require
with its associated properties.globalPreload
hook was removed in v22.LoadHookContext.format
may be null or undefined (corresponding toResolveFnOutput.format
)LoadFnOutput.source
may be undefined if the format does not require a source parameter (eg. builtin modules)findSourceMaps()
has not accepted an error parameter for quite some time.SourceMap
constructor in v20/v22.SourceMap#findEntry()
can return an empty object, similar toSourceMap#findOrigin()
.Module.builtinModules
is immutable.Module.runMain()
accepts an optional parameter.nextLoad
&nextResolve
property optionality #71492 to v18/v20.Please fill in this template.
pnpm test <package to test>
.If changing an existing definition:
package.json
.