@@ -160,13 +160,19 @@ const schemelessBlockList = new SafeSet([
160160 } ;
161161}
162162
163+ /**
164+ * @typedef {import('../../../typings/bindings').InternalBindingMap } InternalBindingMap
165+ */
163166// Set up internalBinding() in the closure.
164167// Do not use `internalBinding` variable name due to the breakage of TypeScript autocompletion.
165- let _internalBinding ;
168+ /**
169+ * @type {<T extends keyof InternalBindingMap>(binding: T) => InternalBindingMap[T] }
170+ */
171+ let internalBinding ;
166172{
167173 const bindingObj = { __proto__ : null } ;
168174 // eslint-disable-next-line no-global-assign
169- _internalBinding = function internalBinding ( module ) {
175+ internalBinding = function internalBinding ( module ) {
170176 let mod = bindingObj [ module ] ;
171177 if ( typeof mod !== 'object' ) {
172178 mod = bindingObj [ module ] = getInternalBinding ( module ) ;
@@ -181,7 +187,7 @@ const {
181187 builtinIds,
182188 compileFunction,
183189 setInternalLoaders,
184- } = _internalBinding ( 'builtins' ) ;
190+ } = internalBinding ( 'builtins' ) ;
185191
186192const getOwn = ( target , property , receiver ) => {
187193 return ObjectPrototypeHasOwnProperty ( target , property ) ?
@@ -279,7 +285,7 @@ class BuiltinModule {
279285
280286 getESMFacade ( ) {
281287 if ( this . module ) return this . module ;
282- const { ModuleWrap } = _internalBinding ( 'module_wrap' ) ;
288+ const { ModuleWrap } = internalBinding ( 'module_wrap' ) ;
283289 // TODO(aduh95): move this to C++, alongside the initialization of the class.
284290 ObjectSetPrototypeOf ( ModuleWrap . prototype , null ) ;
285291 const url = `node:${ this . id } ` ;
@@ -329,7 +335,7 @@ class BuiltinModule {
329335 const fn = compileFunction ( id ) ;
330336 // Arguments must match the parameters specified in
331337 // BuiltinLoader::LookupAndCompile().
332- fn ( this . exports , requireFn , this , process , _internalBinding , primordials ) ;
338+ fn ( this . exports , requireFn , this , process , internalBinding , primordials ) ;
333339
334340 this . loaded = true ;
335341 } finally {
@@ -346,7 +352,7 @@ class BuiltinModule {
346352// Think of this as module.exports in this file even though it is not
347353// written in CommonJS style.
348354const loaderExports = {
349- internalBinding : _internalBinding ,
355+ internalBinding,
350356 BuiltinModule,
351357 require : requireBuiltin ,
352358} ;
@@ -373,4 +379,4 @@ function requireWithFallbackInDeps(request) {
373379}
374380
375381// Store the internal loaders in C++.
376- setInternalLoaders ( _internalBinding , requireBuiltin ) ;
382+ setInternalLoaders ( internalBinding , requireBuiltin ) ;
0 commit comments