Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"./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/timers.d.ts",
"./typings/internalBinding/util.d.ts",
"./typings/internalBinding/worker.d.ts",
"./typings/internalBinding.d.ts",
Expand Down
1 change: 1 addition & 0 deletions typings/internalBinding/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare function InternalBinding(binding: 'options'): {
kAllowedInEnvironment: 0;
kDisallowedInEnvironment: 1;
};
noGlobalSearchPaths: boolean;
shouldNotRegisterESMLoader: boolean;
types: {
kNoOp: 0;
Expand Down
21 changes: 21 additions & 0 deletions typings/internalBinding/os.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare function InternalBinding(binding: 'os'): {
getHostname(ctx: object): string | undefined;
Comment thread
targos marked this conversation as resolved.
Outdated
getLoadAvg(array: Float64Array): void;
getUptime(): number;
getTotalMem(): number;
getFreeMem(): number;
getCPUs(): Array<string | number>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getCPUs(): Array<string | number>;
getCPUs(): (string | number)[];

for consistency with other dts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a preference to use type[] for simple types and Array<types> for more complex ones

getInterfaceAddresses(ctx: object): Array<string | number | boolean> | undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getInterfaceAddresses(ctx: object): Array<string | number | boolean> | undefined;
getInterfaceAddresses(ctx: object): (string | number | boolean)[] | undefined;

getHomeDirectory(ctx: object): string | undefined;
getUserInfo(options: {encoding?: string} | undefined, ctx: object): {
Comment thread
targos marked this conversation as resolved.
Outdated
uid: number;
gid: number;
username: string;
homedir: string;
shell: string | null;
} | undefined;
setPriority(pid: number, priority: number, ctx: object): number;
getPriority(pid: number, ctx: object): number | undefined;
getOSInformation(ctx: object): [sysname: string, version: string, release: string];
isBigEndian: boolean;
};
8 changes: 8 additions & 0 deletions typings/internalBinding/timers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare function InternalBinding(binding: 'timers'): {
getLibuvNow(): number;
setupTimers(immediateCallback: () => void, timersCallback: (now: number) => void): void;
scheduleTimer(msecs: number): void;
toggleTimerRef(value: boolean): void;
toggleImmediateRef(value: boolean): void;
immediateInfo: Uint32Array;
};
1 change: 1 addition & 0 deletions typings/internalBinding/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ declare function InternalBinding(binding: 'util'): {
shouldAbortOnUncaughtToggle: [shouldAbort: 0 | 1];
WeakReference: typeof InternalUtilBinding.WeakReference;
guessHandleType(fd: number): 'TCP' | 'TTY' | 'UDP' | 'FILE' | 'PIPE' | 'UNKNOWN';
toUSVString(str: string, start: number): string;
};
6 changes: 5 additions & 1 deletion typings/primordials.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type StaticApply<T extends (this: unknown, ...args: unknown[]) => unknown> =
* primordials.StringPrototypeStartsWith('thing', 'hello')
* ```
*/
declare namespace primordials {
declare namespace Primordials {
export function uncurryThis<
T extends (...args: unknown[]) => unknown
> (fn: T):
Expand Down Expand Up @@ -527,3 +527,7 @@ declare namespace primordials {
export const PromisePrototypeCatch: UncurryThis<typeof Promise.prototype.catch>
export const PromisePrototypeFinally: UncurryThis<typeof Promise.prototype.finally>
}

declare global {
const primordials: typeof Primordials;
}