@externs/nodejs

中文文档
1.5.0发布于 2019/11/16MITESM + CJS零依赖近 30 天下载 4565

(原始内容存档于2018-10-21). The Close Compiler Externs for Node.JS.

中文使用文档
文档目录33 节
  1. 目录
  2. 方法
  3. API 密码
  4. getExternsDir(): string
  5. 如何使用
  6. 冲突
  7. 警告和待办事宜
  8. 导出=内部
  9. 全球
  10. 节点JS
  11. 活动
  12. 流线
  13. 显示
  14. 页:1
  15. 组
  16. 密码
  17. 单位
  18. Fs 数
  19. 调值
  20. 小时
  21. 小时
  22. Http2 数据
  23. 兹利布
  24. 子进程( P)
  25. UTI 语录
  26. 纯码
  27. 读行
  28. 调用
  29. 用户
  30. 查询字符串
  31. 净额
  32. 妇女
  33. 版权

@ externs/ nodejs (英语)

npm version

@externs/nodejs 是 Google 关闭编译器 Externs for Node.JS.

yarn add -E @externs/nodejs

目录

方法

该方法是使用 tsickle 关于节点JS的类型定义文件(@types/node/index.d.ts) (中文(简体) ). 然而,为准备外观,采取了一些步骤:

  1. 定义被分割为单个文件,从而更容易跟踪警告,并维持每个外部文件必须进行的手动修改.
  2. 当试图生成从 单个文件之间有冲突 declare var Buffer 财务报告和审定财务报表 interface Buffer,哪个 类型脚本 不错,但是 tsickle 无法正确处理 。 为了克服这个 节点缓冲 界面只是被移动到一个单独的文件中,生成其外部文本,然后手动更新以包含来自 var 缓冲。也可以通过宣布 缓冲 作为一门使用静态方法的课, 但我们手动做了.
    // original node.d.ts
    // Declaring both var and interface DOES NOT WORK WITH TSICKLE
    interface Buffer extends NodeBuffer { }
    declare var Buffer: { }
    // later on ...
    interface NodeBuffer extends Uint8Array { }
    
  3. 已经增加了测试 Buffer 界面,以确保工作时没有警告 缓冲 API (英语). 这些测试只是说明如何测试外壳,即确保外壳 海合会 不产生任何警告.
    显示 缓冲 测试(depack test/spec/buffer.js -a --checks_only --externs v8/global/buffer.js --externs v8/global.js 显示没有警告.
    const ab = new ArrayBuffer(16)
    const data = ['hello', 'world']
    const string = 'hello world'
    
    /** @type {!Buffer} */
    var b
    b = new Buffer(string)
    b = new Buffer(string, 'utf8')
    b = new Buffer(100)
    b = new Buffer(new Uint8Array(100))
    b = new Buffer(ab)
    b = new Buffer(data)
    b = new Buffer(b)
    
    b = Buffer.from(ab)
    b = Buffer.from(ab, 10)
    b = Buffer.from(ab, 10, 20)
    
    b = Buffer.from(data)
    b = Buffer.from(string)
    b = Buffer.from(b)
    b = Buffer.from(ab)
    
    b = Buffer.from(string, 'utf8')
    
    /** @type {boolean} */
    var ib = Buffer.isBuffer(string)
    ib = Buffer.isBuffer(b)
    
    /** @type {boolean} */
    var ie = Buffer.isEncoding('utf8')
    ie = Buffer.isEncoding('sirocco5')
    
    /** @type {number} */
    var bl = Buffer.byteLength(string)
    bl = Buffer.byteLength(b)
    bl = Buffer.byteLength(new DataView(ab))
    bl = Buffer.byteLength(ab)
    bl = Buffer.byteLength(string, 'utf8')
    
    b = Buffer.concat([b, b])
    b = Buffer.concat([b, b], 10)
    
    /** @type {number} */
    var n = Buffer.compare(b, b)
    
    b = Buffer.alloc(10)
    b = Buffer.alloc(10, string)
    b = Buffer.alloc(10, b)
    b = Buffer.alloc(10, 10)
    b = Buffer.alloc(10, string, 'utf8')
    
    b = Buffer.allocUnsafe(10)
    
    b = Buffer.allocUnsafeSlow(10)
    
    /** @type {number} */
    var ps = Buffer.poolSize
    
  4. 因为 警告 案件数量 tsickle 无法处理,一些外出人员需要手动更新,通过查看出错消息以及人工检查生成的代码.
  5. 全球仅被定义为: global 对象在 global.d.ts数字 : declare var global: NodeJS.Global;. 这些不会在全球范围传播。 目前,我们不确定.. NodeJS.Global 其他 缓冲 应扩大至全球范围,因为 结束 因为他们是普通的联署机构.
    显示全局
    export interface Global {
        Array: typeof Array;
        ArrayBuffer: typeof ArrayBuffer;
        Boolean: typeof Boolean;
        Buffer: typeof Buffer;
        DataView: typeof DataView;
        Date: typeof Date;
        Error: typeof Error;
        EvalError: typeof EvalError;
        Float32Array: typeof Float32Array;
        Float64Array: typeof Float64Array;
        Function: typeof Function;
        GLOBAL: Global;
        Infinity: typeof Infinity;
        Int16Array: typeof Int16Array;
        Int32Array: typeof Int32Array;
        Int8Array: typeof Int8Array;
        Intl: typeof Intl;
        JSON: typeof JSON;
        Map: MapConstructor;
        Math: typeof Math;
        NaN: typeof NaN;
        Number: typeof Number;
        Object: typeof Object;
        Promise: Function;
        RangeError: typeof RangeError;
        ReferenceError: typeof ReferenceError;
        RegExp: typeof RegExp;
        Set: SetConstructor;
        String: typeof String;
        Symbol: Function;
        SyntaxError: typeof SyntaxError;
        TypeError: typeof TypeError;
        URIError: typeof URIError;
        Uint16Array: typeof Uint16Array;
        Uint32Array: typeof Uint32Array;
        Uint8Array: typeof Uint8Array;
        Uint8ClampedArray: Function;
        WeakMap: WeakMapConstructor;
        WeakSet: WeakSetConstructor;
        // clearImmediate is part of global extern
        clearImmediate: (immediateId: any) => void;
        // clearInterval is skipped by tsickle
        clearInterval: (intervalId: NodeJS.Timer) => void;
        // clearTimeout is skipped by tsickle
        clearTimeout: (timeoutId: NodeJS.Timer) => void;
        // console is part of global extern
        console: typeof console;
        decodeURI: typeof decodeURI;
        decodeURIComponent: typeof decodeURIComponent;
        encodeURI: typeof encodeURI;
        encodeURIComponent: typeof encodeURIComponent;
        escape: (str: string) => string;
        eval: typeof eval;
        // global is part of global extern
        global: Global;
        isFinite: typeof isFinite;
        isNaN: typeof isNaN;
        parseFloat: typeof parseFloat;
        parseInt: typeof parseInt;
        // process is part of global extern
        process: Process;
        // root is NOT part of global extern: SHOULD IT BE?
        root: Global;
        // setImmediate is part of global extern
        setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
        // setInterval is skipped by tsickle
        setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
        // setTimeout is skipped by tsickle
        setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
        undefined: typeof undefined;
        unescape: (str: string) => string;
        gc: () => void;
        v8debug?: any;
    }
    

将声明分入单独文件的问题是,将上游更新合并到其中比较困难,需要做大量人工工作. 因此,理想的情况是,必须设置补丁脚本,以便更新生成的类型,然而,在目前,外部脚本是手动更新的 警告。 。 。 .

API 密码

import getExternsDir, { dependencies } from '@externs/nodejs'

每个单元的外观见于已出版的 v8 目录。 这个 global 财务报告和审定财务报表 nodejs 外部编辑时总是需要在场 节点JS 方案(除非是纯粹的联署材料)。 Externs可能依赖于其他外延,依赖树由此包导出:

/* alanode example/ */
import getExternsDir, { dependencies } from '../src'

console.log('Externs dir: %s', getExternsDir())
console.log('Dependencies:')
console.log(dependencies)
Externs dir: v8
Dependencies:
{ url: [ 'querystring' ],
  stream: [ 'events' ],
  net: [ 'stream', 'events', 'dns' ],
  fs: [ 'stream', 'events', 'url' ],
  tls: [ 'crypto', 'dns', 'net', 'stream' ],
  http: [ 'events', 'net', 'stream', 'url' ],
  https: [ 'tls', 'events', 'http', 'url' ],
  http2: [ 'events', 'fs', 'net', 'stream', 'tls', 'http', 'url' ],
  zlib: [ 'stream' ],
  child_process: [ 'events', 'stream', 'net' ],
  cluster: [ 'child_process', 'events', 'net' ],
  readline: [ 'events', 'stream' ],
  repl: [ 'stream', 'readline' ],
  dgram: [ 'events', 'dns' ],
  string_decoder: [ 'buffer' ],
  domain: [ 'events' ],
  tty: [ 'net' ] }

getExternsDir(): string

运行 require.resolve('@externs/nodejs/package.json') 并添加 v8 ,在结尾指向externs版本8(目前只支持节点8).

如何使用

这些外接器是用来供 拆装:网络和后端节点的依赖捆绑器. JS. 拆装 将在模块上进行基于regex的静态分析,当它们导入一个内部模块(例如, path),它将按需要添加的方式标出外形。 然后,它会添加 require 调用输出包 :

import { join } from 'path'

// will produce the wrapper
const path = require('path')

如何汇编的重要内容 节点JS 软件包在 拆装,是将一个伪内置模块放置在 node_modules。例如,对于 path 内部,将生成以下代码: node_modules/path/index.js数字 :

export default path
export const {
  basename,
  delimiter,
  dirname,
  extname,
  format,
  isAbsolute,
  join,
  normalize,
  parse,
  posix,
  relative,
  resolve,
  sep,
  win32,
} = path

因为 path 以前在输出包件中定义过,并添加了外接器,其所有属性都会被解结构并正确导出.

冲突

这可能需要重新思考...

有3个模块与一些全局变量名称相同: module 财务报告和审定财务报表 console 财务报告和审定财务报表 buffer编辑 crypto 外观 已经存在 输入 海合会因此, 拆装 要求它们使用下划线:

// module !== require('module') so this is good
const _module = require('module')
// console === require('console') so we might change that later
const _console = require('console')
// buffer === require('buffer') so we might change that later
const _buffer = require('buffer')
const _crypto = require('crypto')

警告和待办事宜

在每个外部建筑的形成过程中,都有警告。 这些警告需要人工纠正。 还有 TODO 生成的语句 tsickle 无法进行一些分析。 它们还需要(而且仍然需要)人工修复.

tsickle 无法处理 :

  • PropertySignature数字 :
    export interface IncomingHttpHeaders { 'accept'?: string; }
    
  • IncludesNonWideningType数字 :
    export type ServerOptions = tls.SecureContextOptions & tls.TlsOptions;
    
  • omitting interface deriving from class (并不总是):
    export interface ReadableStream extends EventEmitter { }
    
  • omitting heritage reference to a type/value (不太确定吗? )
    export interface ErrnoException extends Error { }
    

删除来自类的接口 由于某种原因,班级并不总是能够延长另一个班级. 例如 @extends {event.EventEmitter} 在许多依赖它的文件中必须手动添加.

导出=内部

Events 财务报告和审定财务报表 Stream 具有一个类型结构,用于导出一个 internal 属性 :

declare module "events" {
  class internal extends NodeJS.EventEmitter { }

  namespace internal {
    export class EventEmitter extends internal {
      static listenerCount(emitter: EventEmitter, event: string | symbol): number;
      ...
    }
  }

  export = internal;
}

这将导致外部有 internal 属性 :

/**
 * @param {(string|symbol)} type
 * @return {number}
 */
events.internal.EventEmitter.prototype.listenerCount = function(type) {};

这显然不正确,所以 .internal 需要手动删除.

全球

// interface NodeBuffer extends Uint8Array {
types-v8/global.d.ts(188,1): warning TS0: omitting heritage reference to a type/value conflict: Uint8Array
  • 添加 @ extends {Uint8Array} 改为 缓冲。 。 。 .
  • 更新 NodeRequire 可调用,添加 测试数字 :
    在此之前之后
    /**
    * @record
    * @struct
    */
    function NodeRequireFunction() {}
    
    /* TODO: CallSignature:  */
    /**
    * @extends {NodeRequireFunction}
    * @record
    * @struct
    */
    function NodeRequire() {}
    /** @type {!RequireResolve} */
    NodeRequire.prototype.resolve;
    /**
    * @record
    * @struct
    */
    function RequireResolve() {}
    
    /**
     * @param {string} id
     * @returns {?}
     */
    function NodeRequireFunction(id) {}
    
    /* TODO: CallSignature:  */
    /**
    * @param {string} id
    * @returns {*}
    */
    function NodeRequire(id) {}
    /** @type {!RequireResolve} */
    NodeRequire.prototype.resolve;
    /**
    * @param {string} request
    * @param {{paths:!Array<string>}} options
    * @return {string}
    */
    function RequireResolve(request, options) {}
    
  • 这个 NodeModule.prototype.require 不应提及 节点要求 改为 节点需要函数 因为 节点要求 仅仅是一个没有额外属性的函数,例如 .cache 类然而, 节点需要函数 仍然需要更改为从 @struct。 。 。 .

节点JS

节点JS是一个包含其他类引用的API的界面. 虽然没有NodeJSextern这样的东西,但其属性在其他extern上被引用. 因为它也被引用于 global.d.ts,它将永远由 拆装 编辑时 节点JS 程序.

types-v8/nodejs.d.ts(98,3): warning TS0: omitting heritage reference to a type/value conflict: Error
types-v8/nodejs.d.ts(123,3): warning TS0: omitting interface deriving from class: EventEmitter
types-v8/nodejs.d.ts(137,3): warning TS0: omitting interface deriving from class: EventEmitter
types-v8/nodejs.d.ts(149,3): warning TS0: omitting interface deriving from class: EventEmitter
types-v8/nodejs.d.ts(255,3): warning TS0: omitting interface deriving from class: EventEmitter
types-v8/nodejs.d.ts(270,7): warning TS0: should not emit a 'never' type
types-v8/nodejs.d.ts(446,7): warning TS0: anonymous type has no symbol
  • 添加 @extends {Error} 改为 错误例外
  • 添加 @extends {NodeJS.EventEmitter} 改为 可读结构
  • 添加 @extends {NodeJS.EventEmitter} 改为 可写入结构
  • 添加 @extends {NodeJS.EventEmitter} 改为 活动
  • 添加 @extends {NodeJS.EventEmitter} 改为 进程
  • 添加 Intl 类型为 节点JS. Global.prototype. 中国植物物种信息数据库. 输入;
  • 删除 @struct 从 进程Env 防止警告
    test/code.js:7: WARNING - Cannot do '[]' access on a struct
    const output = process.env['OUTPUT']
    
  • 添加 Error.prepareStackTrace 关闭协议 错误 外观.

活动

  • 删除 .internal。 。 。 .

因为事件既是命名空间,又是函数,所以导出的方式如下:

/** @const */
var events = {};
/**
 * @extends {NodeJS.EventEmitter}
 * @constructor
 * @struct
 */
events = function() {};

这将导致编译器警告:

v8/events.js:15: WARNING - accessing name events in externs has no effect. Perhaps you forgot to add a var keyword?
events = function() {};
^^^^^^

v8/events.js:15: WARNING - constant events assigned a value more than once.
Original definition at v8/events.js:9
events = function() {};
^^^^^^^^^^^^^^^^^^^^^^

因此,我们把两个宣言 合并成

/**
 * @extends {NodeJS.EventEmitter}
 * @constructor
 * @struct
 */
var events = function() {};

流线

// export class Duplex extends Readable implements Writable {
types-v8/stream.d.ts(200,7): warning TS0: omitting @implements of a class: Writable
  • 删除 .internal。 。 。 .
  • 因为 @constructor 无法继承一个以上类别 @extends {Writable} 但是,没有添加这些方法,因为这些方法被界定为执行 Writable 接口,它们被添加到双面原型本身.

与 事件 (见上文),将声明倒闭为 var 定义.

/**
 * @extends {events.EventEmitter}
 * @constructor
 * @struct
 */
var stream = function() {};

显示

// export function fail(message?: string): never;
types-v8/assert.d.ts(19,7): warning TS0: should not emit a 'never' type

// export function fail(actual: any, expected: any, message?: string, operator?: string, stackStartFn?: Function): never;
types-v8/assert.d.ts(20,7): warning TS0: should not emit a 'never' type
  • 删除 .internal 财务报告和审定财务报表 {} 命名空间声明(描述见事件).
  • 尽管警告 AssertionError 正在扩展 Error。 。 。 .
    // export class AssertionError implements Error {
    types-v8/assert.d.ts(4,7): warning TS0: omitting heritage reference to a type/value conflict: Error
    

类型中缺少的方法

  • doesNotReject 添加于 V8.13.0
  • rejects 添加于 V8.13.0
  • strict 添加于 V8.13.0

页:1

有一些缺失的API出现在了节点8中,这些API不存在类型.

类型中缺少的方法

  • serialize
  • deserialize
  • cachedDataVersionTag
  • Serializer
  • Deserializer
  • DefaultSerializer
  • DefaultDeserializer

组

  • 已经存在 @ extends {events.EventEmitter} 改为 组。 。 。 .
    // export interface Cluster extends events.EventEmitter {
    types-v8/cluster.d.ts(98,3): warning TS0: omitting interface deriving from class: events.EventEmitter
    

类型中缺少的方法

  • SCHED_NONE
  • SCHED_RR
  • domain
  • schedulingPolicy

密码

这个 crypto 外观 已经存在 内 海合会,因此,外部的命名空间被添加为`密码。 。 。 .

types-v8/crypto.d.ts(10,14): warning TS0: type/symbol conflict for Certificate, using {?} for now
  • 修复 Certificate 冲突.

类型中缺少的方法

  • Cipheriv
  • Decipheriv
  • DiffieHellmanGroup
  • Sign
  • constants
  • createDiffieHellmanGroup
  • prng
  • rng
  • setEngine

单位

types-v8/dns.d.ts(272,7): warning TS0: unhandled anonymous type with multiple call signatures

types-v8/dns.d.ts(273,7): warning TS0: unhandled anonymous type with multiple call signatures

types-v8/dns.d.ts(274,7): warning TS0: unhandled anonymous type with multiple call signatures

这个 解析器 类有 resolve, (中文(简体) ), resolve4, (中文(简体) ), resolve6 但是,这些方法有多个调用签名.

export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
// + N more

export class Resolver {
  ...
  resolve: typeof resolve;
  resolve4: typeof resolve4;
  resolve6: typeof resolve6;

这意味着外接器无法生成 .

/** @type {?} */
dns.Resolver.prototype.resolve;
/** @type {?} */
dns.Resolver.prototype.resolve4;
/** @type {?} */
dns.Resolver.prototype.resolve6;
  • 为每种方法添加一个类型.

Fs 数

//   export interface FSWatcher extends events.EventEmitter {
types-v8/fs.d.ts(46,3): warning TS0: omitting interface deriving from class: events.EventEmitter

调值

// export interface ClearTextStream extends stream.Duplex {
types-v8/tls.d.ts(327,3): warning TS0: omitting interface deriving from class: stream.Duplex

小时

更新属性签名 .

/* TODO: PropertySignature: http.'accept' */
  • 添加属性签名 .
  • 添加 maxHeaderSize 类型.

小时

types-v8/https.d.ts(12,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/https.d.ts(25,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/https.d.ts(44,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/https.d.ts(45,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/https.d.ts(46,3): warning TS0: unhandled type flags: IncludesNonWideningType

Http2 数据

// export interface Http2Stream extends stream.Duplex {
types-v8/http2.d.ts(61,3): warning TS0: omitting interface deriving from class: stream.Duplex

// export interface Http2Session extends events.EventEmitter {
types-v8/http2.d.ts(248,3): warning TS0: omitting interface deriving from class: events.EventEmitter

// export interface Http2Server extends net.Server {
types-v8/http2.d.ts(405,3): warning TS0: omitting interface deriving from class: net.Server

// export interface Http2SecureServer extends tls.Server {
types-v8/http2.d.ts(449,3): warning TS0: omitting interface deriving from class: tls.Server

兹利布

types-v8/zlib.d.ts(32,3): warning TS0: omitting interface deriving from class: stream.Transform

types-v8/zlib.d.ts(33,3): warning TS0: omitting interface deriving from class: stream.Transform

types-v8/zlib.d.ts(34,3): warning TS0: omitting interface deriving from class: stream.Transform

types-v8/zlib.d.ts(35,3): warning TS0: omitting interface deriving from class: stream.Transform

types-v8/zlib.d.ts(36,3): warning TS0: omitting interface deriving from class: stream.Transform

types-v8/zlib.d.ts(37,3): warning TS0: omitting interface deriving from class: stream.Transform

types-v8/zlib.d.ts(38,3): warning TS0: omitting interface deriving from class: stream.Transform

子进程( P)

types-v8/child_process.d.ts(10,3): warning TS0: omitting interface deriving from class: events.EventEmitter

types-v8/child_process.d.ts(126,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(129,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(133,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(139,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(144,7): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(145,7): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(147,7): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(172,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(174,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(198,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(199,3): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(213,7): warning TS0: unhandled type flags: IncludesNonWideningType

types-v8/child_process.d.ts(214,7): warning TS0: unhandled type flags: IncludesNonWideningType

UTI 语录

// export var inspect: {
types-v8/util.d.ts(11,14): warning TS0: unhandled anonymous type

在这里 inspect 其所有可能的签名均用卷括号来定义. tsickle 这不理解.

export var inspect: {
  (object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
  (object: any, options: InspectOptions): string;
  colors: {
    [color: string]: [number, number] | undefined
  }
  styles: {
    [style: string]: string | undefined
  }
  defaultOptions: InspectOptions;
  custom: symbol;
};
// export interface CustomPromisify<TCustom extends Function> extends Function {
types-v8/util.d.ts(42,3): warning TS0: omitting heritage reference to a type/value conflict: Function

纯码

//   export var ucs2: ucs2;
types-v8/punycode.d.ts(6,14): warning TS0: type/symbol conflict for ucs2, using {?} for now

读行

// export interface ReadLine extends events.EventEmitter {
types-v8/readline.d.ts(17,3): warning TS0: omitting interface deriving from class: events.EventEmitter
  • 重命名 interface 参数到 _interface,否则显示以下错误:
    @externs/nodejs/v8/readline.js:185: ERROR - Parse error. ')' expected
    readline.emitKeypressEvents = function(stream, interface) {};
                                                  ^
    

调用

// export class Recoverable extends SyntaxError {
types-v8/repl.d.ts(65,3): warning TS0: omitting heritage reference to a type/value conflict: SyntaxError

用户

node_modules/util/index.js:11: WARNING - Property getSystemErrorName never defined on util
  getSystemErrorName,
  ^^^^^^^^^^^^^^^^^^

- [x] 添加到 util.getSystemErrorName 以手动复制.

查询字符串

- [x] 添加 decode 财务报告和审定财务报表 encode 别名改为 parse 财务报告和审定财务报表 stringify。 。 。 .

净额

- [x] 添加数据 Stream 别名改为 Socket (目前该类型不正确,即:, /** @type {net.Socket} */ net.Stream。此选项指定了实例类型,而不是构造器类型.

妇女

目前,在有些忽略了externs中没有定义的属性和方法之后,仍有一些警告还没有处理.

node_modules/buffer/index.js:6: WARNING - [JSC_INEXISTENT_PROPERTY] Property constants never defined on buffer
  constants,
  ^^^^^^^^^

node_modules/buffer/index.js:7: WARNING - [JSC_INEXISTENT_PROPERTY] Property kMaxLength never defined on buffer
  kMaxLength,
  ^^^^^^^^^^

node_modules/buffer/index.js:8: WARNING - [JSC_INEXISTENT_PROPERTY] Property kStringMaxLength never defined on buffer
  kStringMaxLength,
  ^^^^^^^^^^^^^^^^

node_modules/console/index.js:6: WARNING - [JSC_INEXISTENT_PROPERTY] Property context never defined on Console
  context,
  ^^^^^^^

node_modules/constants/index.js:4: WARNING - [JSC_INEXISTENT_PROPERTY] Property COPYFILE_EXCL never defined on constants
  COPYFILE_EXCL,
  ^^^^^^^^^^^^^

node_modules/constants/index.js:27: WARNING - [JSC_INEXISTENT_PROPERTY] Property EDQUOT never defined on constants
  EDQUOT,
  ^^^^^^

node_modules/constants/index.js:44: WARNING - [JSC_INEXISTENT_PROPERTY] Property EMULTIHOP never defined on constants
  EMULTIHOP,
  ^^^^^^^^^

node_modules/constants/index.js:95: WARNING - [JSC_INEXISTENT_PROPERTY] Property ESTALE never defined on constants
  ESTALE,
  ^^^^^^

node_modules/constants/index.js:103: WARNING - [JSC_INEXISTENT_PROPERTY] Property OPENSSL_VERSION_NUMBER never defined on constants
  OPENSSL_VERSION_NUMBER,
  ^^^^^^^^^^^^^^^^^^^^^^

node_modules/constants/index.js:125: WARNING - [JSC_INEXISTENT_PROPERTY] Property RSA_PSS_SALTLEN_AUTO never defined on constants
  RSA_PSS_SALTLEN_AUTO,
  ^^^^^^^^^^^^^^^^^^^^

node_modules/constants/index.js:126: WARNING - [JSC_INEXISTENT_PROPERTY] Property RSA_PSS_SALTLEN_DIGEST never defined on constants
  RSA_PSS_SALTLEN_DIGEST,
  ^^^^^^^^^^^^^^^^^^^^^^

node_modules/constants/index.js:127: WARNING - [JSC_INEXISTENT_PROPERTY] Property RSA_PSS_SALTLEN_MAX_SIGN never defined on constants
  RSA_PSS_SALTLEN_MAX_SIGN,
  ^^^^^^^^^^^^^^^^^^^^^^^^

node_modules/constants/index.js:139: WARNING - [JSC_INEXISTENT_PROPERTY] Property SIGINFO never defined on constants
  SIGINFO,
  ^^^^^^^

node_modules/constants/index.js:216: WARNING - [JSC_INEXISTENT_PROPERTY] Property UV_FS_COPYFILE_EXCL never defined on constants
  UV_FS_COPYFILE_EXCL,
  ^^^^^^^^^^^^^^^^^^^

node_modules/domain/index.js:4: WARNING - [JSC_INEXISTENT_PROPERTY] Property active never defined on domain
  active,
  ^^^^^^

node_modules/domain/index.js:6: WARNING - [JSC_INEXISTENT_PROPERTY] Property createDomain never defined on domain
  createDomain,
  ^^^^^^^^^^^^

node_modules/http2/index.js:3: WARNING - [JSC_BAD_PRIVATE_PROPERTY_ACCESS] Access to private property Http2ServerRequest of {
  ClientHttp2Session: (typeof http2.ClientHttp2Session),
  ClientHttp2Stream: (typeof http2.ClientHttp2Stream),
  ClientSessionOptions: None,
  ClientSessionRequestOptions: (typeof http2.ClientSessionRequestOptions),
  Http2SecureServer: (typeof http2.Http2SecureServer),
  Http2Server: (typeof http2.Http2Server),
  Http2ServerRequest: (typeof http2.Http2ServerRequest),
  Http2ServerResponse: (typeof http2.Http2ServerResponse),
  Http2Session: (typeof http2.Http2Session),
  Http2Stream: (typeof http2.Http2Stream), ...
} not allowed here.
  Http2ServerRequest,
  ^^^^^^^^^^^^^^^^^^

node_modules/http2/index.js:4: WARNING - [JSC_BAD_PRIVATE_PROPERTY_ACCESS] Access to private property Http2ServerResponse of {
  ClientHttp2Session: (typeof http2.ClientHttp2Session),
  ClientHttp2Stream: (typeof http2.ClientHttp2Stream),
  ClientSessionOptions: None,
  ClientSessionRequestOptions: (typeof http2.ClientSessionRequestOptions),
  Http2SecureServer: (typeof http2.Http2SecureServer),
  Http2Server: (typeof http2.Http2Server),
  Http2ServerRequest: (typeof http2.Http2ServerRequest),
  Http2ServerResponse: (typeof http2.Http2ServerResponse),
  Http2Session: (typeof http2.Http2Session),
  Http2Stream: (typeof http2.Http2Stream), ...
} not allowed here.
  Http2ServerResponse,
  ^^^^^^^^^^^^^^^^^^^

node_modules/process/index.js:7: WARNING - [JSC_INEXISTENT_PROPERTY] Property assert never defined on NodeJS.Process
  assert,
  ^^^^^^

node_modules/process/index.js:8: WARNING - [JSC_INEXISTENT_PROPERTY] Property binding never defined on NodeJS.Process
  binding,
  ^^^^^^^

node_modules/process/index.js:14: WARNING - [JSC_INEXISTENT_PROPERTY] Property dlopen never defined on NodeJS.Process
  dlopen,
  ^^^^^^

node_modules/process/index.js:21: WARNING - [JSC_INEXISTENT_PROPERTY] Property features never defined on NodeJS.Process
  features,
  ^^^^^^^^

node_modules/process/index.js:28: WARNING - [JSC_INEXISTENT_PROPERTY] Property initgroups never defined on NodeJS.Process
  initgroups,
  ^^^^^^^^^^

node_modules/process/index.js:32: WARNING - [JSC_INEXISTENT_PROPERTY] Property moduleLoadList never defined on NodeJS.Process
  moduleLoadList,
  ^^^^^^^^^^^^^^

node_modules/process/index.js:37: WARNING - [JSC_INEXISTENT_PROPERTY] Property ppid never defined on NodeJS.Process
  ppid,
  ^^^^

node_modules/process/index.js:38: WARNING - [JSC_INEXISTENT_PROPERTY] Property reallyExit never defined on NodeJS.Process
  reallyExit,
  ^^^^^^^^^^

node_modules/repl/index.js:4: WARNING - [JSC_INEXISTENT_PROPERTY] Property REPL_MODE_MAGIC never defined on repl
  REPL_MODE_MAGIC,
  ^^^^^^^^^^^^^^^

node_modules/repl/index.js:5: WARNING - [JSC_INEXISTENT_PROPERTY] Property REPL_MODE_SLOPPY never defined on repl
  REPL_MODE_SLOPPY,
  ^^^^^^^^^^^^^^^^

node_modules/repl/index.js:6: WARNING - [JSC_INEXISTENT_PROPERTY] Property REPL_MODE_STRICT never defined on repl
  REPL_MODE_STRICT,
  ^^^^^^^^^^^^^^^^

node_modules/repl/index.js:9: WARNING - [JSC_INEXISTENT_PROPERTY] Property writer never defined on repl
  writer,
  ^^^^^^

node_modules/timers/index.js:3: WARNING - [JSC_INEXISTENT_PROPERTY] Property active never defined on timers
  active,
  ^^^^^^

node_modules/timers/index.js:7: WARNING - [JSC_INEXISTENT_PROPERTY] Property enroll never defined on timers
  enroll,
  ^^^^^^

node_modules/timers/index.js:11: WARNING - [JSC_INEXISTENT_PROPERTY] Property unenroll never defined on timers
  unenroll,
  ^^^^^^^^

node_modules/tls/index.js:5: WARNING - [JSC_INEXISTENT_PROPERTY] Property DEFAULT_CIPHERS never defined on tls
  DEFAULT_CIPHERS,
  ^^^^^^^^^^^^^^^

node_modules/tls/index.js:7: WARNING - [JSC_INEXISTENT_PROPERTY] Property SLAB_BUFFER_SIZE never defined on tls
  SLAB_BUFFER_SIZE,
  ^^^^^^^^^^^^^^^^

node_modules/tls/index.js:13: WARNING - [JSC_INEXISTENT_PROPERTY] Property convertALPNProtocols never defined on tls
  convertALPNProtocols,
  ^^^^^^^^^^^^^^^^^^^^

node_modules/tls/index.js:14: WARNING - [JSC_INEXISTENT_PROPERTY] Property convertNPNProtocols never defined on tls
  convertNPNProtocols,
  ^^^^^^^^^^^^^^^^^^^

node_modules/tls/index.js:19: WARNING - [JSC_INEXISTENT_PROPERTY] Property parseCertString never defined on tls
  parseCertString,
  ^^^^^^^^^^^^^^^

0 error(s), 38 warning(s), 97.5% typed

版权属于作者.

节点.js 8.10的定义类型 通过:

从 https://github.com/Definitely Typed/Definitely Typed 互联网档案馆的存檔,存档日期2014-12-22

Art Deco © 艺术代科 页:1 拆装 2019 (英语) Tech Nation Visa 国家技术签证

版本与发布记录

@externs/nodejs 共发布 1 个版本,首次发布于 2019/11/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.5.0latest2019/11/166 年前

关于 @externs/nodejs 的常见问题

@externs/nodejs 是什么?

(原始内容存档于2018-10-21). The Close Compiler Externs for Node.JS.

如何安装 @externs/nodejs?

在项目目录运行 npm install @externs/nodejs,或使用 pnpm add / yarn add / bun add。

@externs/nodejs 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/externs__nodejs 是否存在。

@externs/nodejs 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@externs/nodejs 可以商用吗?

@externs/nodejs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@externs/nodejs 的下载量有多少?

根据 npm 官方下载统计,@externs/nodejs 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,565 次,日均约 152 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@externs/nodejs 还在维护吗?

最新版本 1.5.0 发布于 2019/11/16(6 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/11/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。