From 12f5a684850032d3b111df8bd0bc9cfff497b368 Mon Sep 17 00:00:00 2001 From: Mestery Date: Mon, 11 Oct 2021 18:08:34 +0200 Subject: [PATCH] typings: separate `internalBinding` typings --- tsconfig.json | 6 ++- typings/globals.d.ts | 1 + typings/internalBinding/config.d.ts | 12 ++++++ .../constants.d.ts} | 42 ------------------- typings/internalBinding/symbols.d.ts | 3 ++ typings/internalBinding/types.d.ts | 26 ++++++++++++ 6 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 typings/globals.d.ts create mode 100644 typings/internalBinding/config.d.ts rename typings/{internalBinding.d.ts => internalBinding/constants.d.ts} (84%) create mode 100644 typings/internalBinding/symbols.d.ts create mode 100644 typings/internalBinding/types.d.ts diff --git a/tsconfig.json b/tsconfig.json index 048ecd6f48e3ee..ea179268d9a684 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,16 +2,20 @@ "include": ["lib","doc"], "exclude": ["src","tools","out"], "files": [ + "./typings/internalBinding/config.d.ts", + "./typings/internalBinding/constants.d.ts", "./typings/internalBinding/fs.d.ts", "./typings/internalBinding/http_parser.d.ts", "./typings/internalBinding/messaging.d.ts", "./typings/internalBinding/options.d.ts", "./typings/internalBinding/os.d.ts", "./typings/internalBinding/serdes.d.ts", + "./typings/internalBinding/symbols.d.ts", "./typings/internalBinding/timers.d.ts", + "./typings/internalBinding/types.d.ts", "./typings/internalBinding/util.d.ts", "./typings/internalBinding/worker.d.ts", - "./typings/internalBinding.d.ts", + "./typings/globals.d.ts", "./typings/primordials.d.ts" ], "compilerOptions": { diff --git a/typings/globals.d.ts b/typings/globals.d.ts new file mode 100644 index 00000000000000..5d849b28b66ba0 --- /dev/null +++ b/typings/globals.d.ts @@ -0,0 +1 @@ +declare type TypedArray = Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray | Int16Array | Int32Array | Int8Array | BigInt64Array | Float32Array | Float64Array | BigUint64Array; diff --git a/typings/internalBinding/config.d.ts b/typings/internalBinding/config.d.ts new file mode 100644 index 00000000000000..3fccf4007f145b --- /dev/null +++ b/typings/internalBinding/config.d.ts @@ -0,0 +1,12 @@ +declare function InternalBinding(binding: 'config'): { + isDebugBuild: boolean, + hasOpenSSL: boolean, + fipsMode: boolean, + hasIntl: boolean, + hasTracing: boolean, + hasNodeOptions: boolean, + hasInspector: boolean, + noBrowserGlobals: boolean, + bits: number, + hasDtrace: boolean +} diff --git a/typings/internalBinding.d.ts b/typings/internalBinding/constants.d.ts similarity index 84% rename from typings/internalBinding.d.ts rename to typings/internalBinding/constants.d.ts index ffb6423e3e5d87..802a0c019f6096 100644 --- a/typings/internalBinding.d.ts +++ b/typings/internalBinding/constants.d.ts @@ -1,30 +1,3 @@ -declare type TypedArray = Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray | Int16Array | Int32Array | Int8Array | BigInt64Array | Float32Array | Float64Array | BigUint64Array; -declare function InternalBinding(binding: 'types'): { - isAsyncFunction(value: unknown): value is (...args: unknown[]) => Promise, - isGeneratorFunction(value: unknown): value is GeneratorFunction, - isAnyArrayBuffer(value: unknown): value is (ArrayBuffer | SharedArrayBuffer), - isArrayBuffer(value: unknown): value is ArrayBuffer, - isArgumentsObject(value: unknown): value is ArrayLike, - isBoxedPrimitive(value: unknown): value is (BigInt | Boolean | Number | String | Symbol), - isDataView(value: unknown): value is DataView, - isExternal(value: unknown): value is Object, - isMap(value: unknown): value is Map, - isMapIterator: (value: unknown) => value is IterableIterator, - isModuleNamespaceObject: (value: unknown) => value is {[Symbol.toStringTag]: 'Module', [key: string]: any}, - isNativeError: (value: unknown) => Error, - isPromise: (value: unknown) => value is Promise, - isSet: (value: unknown) => value is Set, - isSetIterator: (value: unknown) => value is IterableIterator, - isWeakMap: (value: unknown) => value is WeakMap, - isWeakSet: (value: unknown) => value is WeakSet, - isRegExp: (value: unknown) => RegExp, - isDate: (value: unknown) => Date, - isTypedArray: (value: unknown) => value is TypedArray, - isStringObject: (value: unknown) => value is String, - isNumberObject: (value: unknown) => value is Number, - isBooleanObject: (value: unknown) => value is Boolean, - isBigIntObject: (value: unknown) => value is BigInt, -}; declare function InternalBinding(binding: 'constants'): { os: { UV_UDP_REUSEADDR: 4, @@ -427,18 +400,3 @@ declare function InternalBinding(binding: 'constants'): { TRACE_EVENT_PHASE_LINK_IDS: 61 } }; -declare function InternalBinding(binding: 'config'): { - isDebugBuild: boolean, - hasOpenSSL: boolean, - fipsMode: boolean, - hasIntl: boolean, - hasTracing: boolean, - hasNodeOptions: boolean, - hasInspector: boolean, - noBrowserGlobals: boolean, - bits: number, - hasDtrace: boolean -} -declare function InternalBinding(binding: 'symbols'): { - [name: string]: symbol; -} diff --git a/typings/internalBinding/symbols.d.ts b/typings/internalBinding/symbols.d.ts new file mode 100644 index 00000000000000..af49504f84b329 --- /dev/null +++ b/typings/internalBinding/symbols.d.ts @@ -0,0 +1,3 @@ +declare function InternalBinding(binding: 'symbols'): { + [name: string]: symbol; +} diff --git a/typings/internalBinding/types.d.ts b/typings/internalBinding/types.d.ts new file mode 100644 index 00000000000000..6d01da4b535ed4 --- /dev/null +++ b/typings/internalBinding/types.d.ts @@ -0,0 +1,26 @@ +declare function InternalBinding(binding: 'types'): { + isAsyncFunction(value: unknown): value is (...args: unknown[]) => Promise, + isGeneratorFunction(value: unknown): value is GeneratorFunction, + isAnyArrayBuffer(value: unknown): value is (ArrayBuffer | SharedArrayBuffer), + isArrayBuffer(value: unknown): value is ArrayBuffer, + isArgumentsObject(value: unknown): value is ArrayLike, + isBoxedPrimitive(value: unknown): value is (BigInt | Boolean | Number | String | Symbol), + isDataView(value: unknown): value is DataView, + isExternal(value: unknown): value is Object, + isMap(value: unknown): value is Map, + isMapIterator: (value: unknown) => value is IterableIterator, + isModuleNamespaceObject: (value: unknown) => value is {[Symbol.toStringTag]: 'Module', [key: string]: any}, + isNativeError: (value: unknown) => Error, + isPromise: (value: unknown) => value is Promise, + isSet: (value: unknown) => value is Set, + isSetIterator: (value: unknown) => value is IterableIterator, + isWeakMap: (value: unknown) => value is WeakMap, + isWeakSet: (value: unknown) => value is WeakSet, + isRegExp: (value: unknown) => RegExp, + isDate: (value: unknown) => Date, + isTypedArray: (value: unknown) => value is TypedArray, + isStringObject: (value: unknown) => value is String, + isNumberObject: (value: unknown) => value is Number, + isBooleanObject: (value: unknown) => value is Boolean, + isBigIntObject: (value: unknown) => value is BigInt, +};