Skip to content

Commit 1db475b

Browse files
OwnageIsMagicAndy
authored and
Andy
committed
Node 9.3 (#22593)
* SignalsListener signal name nodejs/node#15606 * created Node 8 folder * Create tsconfig.json * Create tslint.json * Create node-tests.ts * Node 9 * update node header * Tabs to spaces * copy inspector.d.ts to v8 folder * correct path mapping for v8 * disable no-declare-current-package for v8 module * Correct version to 9.3.x Add writableHighWaterMark/readableHighWaterMark to WriteStream/ReadStream fixed setUncaughtExceptionCaptureCallback() Add module.builtinModules change os.EOL to const add writableHighWaterMark to Duplex writableHighWaterMark and readableHighWaterMark are readonly * fs.realpathSync.native and fs.realpath.native * fs.realpath.native tests
1 parent 4bd00a5 commit 1db475b

7 files changed

+13634
-11
lines changed

index.d.ts

+24-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for Node.js 8.5.x
1+
// Type definitions for Node.js 9.3.x
22
// Project: http://nodejs.org/
33
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
44
// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
@@ -20,12 +20,6 @@
2020
// Klaus Meinhardt <https://github.com/ajafff>
2121
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
2222

23-
/************************************************
24-
* *
25-
* Node.js v8.5.x API *
26-
* *
27-
************************************************/
28-
2923
/** inspector module types */
3024
/// <reference path="./inspector.d.ts" />
3125

@@ -34,6 +28,7 @@ interface Console {
3428
Console: NodeJS.ConsoleConstructor;
3529
assert(value: any, message?: string, ...optionalParams: any[]): void;
3630
dir(obj: any, options?: NodeJS.InspectOptions): void;
31+
debug(message?: any, ...optionalParams: any[]): void;
3732
error(message?: any, ...optionalParams: any[]): void;
3833
info(message?: any, ...optionalParams: any[]): void;
3934
log(message?: any, ...optionalParams: any[]): void;
@@ -457,7 +452,6 @@ declare namespace NodeJS {
457452
remove(emitter: Events): void;
458453
bind(cb: (err: Error, data: any) => any): any;
459454
intercept(cb: (data: any) => any): any;
460-
dispose(): void;
461455

462456
addListener(event: string, listener: (...args: any[]) => void): this;
463457
on(event: string, listener: (...args: any[]) => void): this;
@@ -512,7 +506,7 @@ declare namespace NodeJS {
512506
type UnhandledRejectionListener = (reason: any, promise: Promise<any>) => void;
513507
type WarningListener = (warning: Error) => void;
514508
type MessageListener = (message: any, sendHandle: any) => void;
515-
type SignalsListener = () => void;
509+
type SignalsListener = (signal: Signals) => void;
516510
type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
517511
type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
518512

@@ -525,6 +519,7 @@ declare namespace NodeJS {
525519
}
526520

527521
export interface WriteStream extends Socket {
522+
readonly writableHighWaterMark: number;
528523
columns?: number;
529524
rows?: number;
530525
_write(chunk: any, encoding: string, callback: Function): void;
@@ -536,6 +531,7 @@ declare namespace NodeJS {
536531
destroy(error?: Error): void;
537532
}
538533
export interface ReadStream extends Socket {
534+
readonly readableHighWaterMark: number;
539535
isRaw?: boolean;
540536
setRawMode?(mode: boolean): void;
541537
_read(size: number): void;
@@ -570,6 +566,8 @@ declare namespace NodeJS {
570566
setegid(id: number | string): void;
571567
getgroups(): number[];
572568
setgroups(groups: Array<string | number>): void;
569+
setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
570+
hasUncaughtExceptionCaptureCallback(): boolean;
573571
version: string;
574572
versions: ProcessVersions;
575573
config: {
@@ -600,6 +598,7 @@ declare namespace NodeJS {
600598
};
601599
kill(pid: number, signal?: string | number): void;
602600
pid: number;
601+
ppid: number;
603602
title: string;
604603
arch: string;
605604
platform: Platform;
@@ -790,6 +789,7 @@ declare namespace NodeJS {
790789
class Module {
791790
static runMain(): void;
792791
static wrap(code: string): string;
792+
static builtinModules: string[];
793793

794794
static Module: typeof Module;
795795

@@ -1725,7 +1725,7 @@ declare module "os" {
17251725
export function arch(): string;
17261726
export function platform(): NodeJS.Platform;
17271727
export function tmpdir(): string;
1728-
export var EOL: string;
1728+
export const EOL: string;
17291729
export function endianness(): "BE" | "LE";
17301730
}
17311731

@@ -3514,6 +3514,11 @@ declare module "fs" {
35143514
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
35153515
*/
35163516
export function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
3517+
3518+
export function native(path: PathLike, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void;
3519+
export function native(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException, resolvedPath: Buffer) => void): void;
3520+
export function native(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string | Buffer) => void): void;
3521+
export function native(path: PathLike, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void;
35173522
}
35183523

35193524
/**
@@ -3537,6 +3542,12 @@ declare module "fs" {
35373542
*/
35383543
export function realpathSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
35393544

3545+
export namespace realpathSync {
3546+
export function native(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
3547+
export function native(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
3548+
export function native(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
3549+
}
3550+
35403551
/**
35413552
* Asynchronous unlink(2) - delete a name and possibly the file it refers to.
35423553
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -5293,6 +5304,7 @@ declare module "stream" {
52935304

52945305
export class Readable extends Stream implements NodeJS.ReadableStream {
52955306
readable: boolean;
5307+
readableHighWaterMark: number;
52965308
constructor(opts?: ReadableOptions);
52975309
_read(size: number): void;
52985310
read(size?: number): any;
@@ -5379,6 +5391,7 @@ declare module "stream" {
53795391

53805392
export class Writable extends Stream implements NodeJS.WritableStream {
53815393
writable: boolean;
5394+
readonly writableHighWaterMark: number;
53825395
constructor(opts?: WritableOptions);
53835396
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
53845397
_writev?(chunks: Array<{chunk: any, encoding: string}>, callback: (err?: Error) => void): void;
@@ -5470,6 +5483,7 @@ declare module "stream" {
54705483
// Note: Duplex extends both Readable and Writable.
54715484
export class Duplex extends Readable implements Writable {
54725485
writable: boolean;
5486+
readonly writableHighWaterMark: number;
54735487
constructor(opts?: DuplexOptions);
54745488
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
54755489
_writev?(chunks: Array<{chunk: any, encoding: string}>, callback: (err?: Error) => void): void;
@@ -5649,7 +5663,6 @@ declare module "domain" {
56495663
remove(emitter: events.EventEmitter): void;
56505664
bind(cb: (err: Error, data: any) => any): any;
56515665
intercept(cb: (data: any) => any): any;
5652-
dispose(): void;
56535666
members: any[];
56545667
enter(): void;
56555668
exit(): void;

node-tests.ts

+34
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,32 @@ namespace fs_tests {
339339
b = fs.realpathSync('/path/to/folder', { encoding: 'buffer' });
340340
const v2 = fs.realpathSync('/path/to/folder', { encoding: s });
341341
typeof v2 === "string" ? s = v2 : b = v2;
342+
343+
// native
344+
fs.realpath.native('/path/to/folder', (err, resolvedPath) => s = resolvedPath);
345+
fs.realpath.native('/path/to/folder', undefined, (err, resolvedPath) => s = resolvedPath);
346+
fs.realpath.native('/path/to/folder', 'utf8', (err, resolvedPath) => s = resolvedPath);
347+
fs.realpath.native('/path/to/folder', 'buffer', (err, resolvedPath) => b = resolvedPath);
348+
fs.realpath.native('/path/to/folder', s, (err, resolvedPath) => typeof resolvedPath === 'string' ? s = resolvedPath : b = resolvedPath);
349+
fs.realpath.native('/path/to/folder', {}, (err, resolvedPath) => s = resolvedPath);
350+
fs.realpath.native('/path/to/folder', { encoding: undefined }, (err, resolvedPath) => s = resolvedPath);
351+
fs.realpath.native('/path/to/folder', { encoding: 'utf8' }, (err, resolvedPath) => s = resolvedPath);
352+
fs.realpath.native('/path/to/folder', { encoding: 'buffer' }, (err, resolvedPath) => b = resolvedPath);
353+
fs.realpath.native('/path/to/folder', { encoding: s }, (err, resolvedPath) => typeof resolvedPath === "string" ? s = resolvedPath : b = resolvedPath);
354+
355+
s = fs.realpathSync.native('/path/to/folder');
356+
s = fs.realpathSync.native('/path/to/folder', undefined);
357+
s = fs.realpathSync.native('/path/to/folder', 'utf8');
358+
b = fs.realpathSync.native('/path/to/folder', 'buffer');
359+
const v3 = fs.realpathSync.native('/path/to/folder', s);
360+
typeof v3 === "string" ? s = v3 : b = v3;
361+
362+
s = fs.realpathSync.native('/path/to/folder', {});
363+
s = fs.realpathSync.native('/path/to/folder', { encoding: undefined });
364+
s = fs.realpathSync.native('/path/to/folder', { encoding: 'utf8' });
365+
b = fs.realpathSync.native('/path/to/folder', { encoding: 'buffer' });
366+
const v4 = fs.realpathSync.native('/path/to/folder', { encoding: s });
367+
typeof v4 === "string" ? s = v4 : b = v4;
342368
}
343369

344370
{
@@ -2608,6 +2634,13 @@ namespace process_tests {
26082634
const oldHandler = listeners[listeners.length - 1];
26092635
process.addListener('uncaughtException', oldHandler);
26102636
}
2637+
{
2638+
function myCb(err: Error): void {
2639+
}
2640+
process.setUncaughtExceptionCaptureCallback(myCb);
2641+
process.setUncaughtExceptionCaptureCallback(null);
2642+
const b: boolean = process.hasUncaughtExceptionCaptureCallback();
2643+
}
26112644
}
26122645

26132646
///////////////////////////////////////////////////////////
@@ -3913,6 +3946,7 @@ namespace module_tests {
39133946

39143947
const m1: Module = new Module("moduleId");
39153948
const m2: Module = new Module.Module("moduleId");
3949+
const b: string[] = Module.builtinModules;
39163950
let paths: string[] = module.paths;
39173951
paths = m1.paths;
39183952
}

0 commit comments

Comments
 (0)