diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 78af71a935..8995900e3e 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package Node.js 13.5 +// Type definitions for non-npm package Node.js 13.7 // Project: http://nodejs.org/ // Definitions by: Microsoft TypeScript // DefinitelyTyped diff --git a/types/node/module.d.ts b/types/node/module.d.ts index 4fbfbbb459..2654f4216c 100644 --- a/types/node/module.d.ts +++ b/types/node/module.d.ts @@ -1,6 +1,43 @@ declare module "module" { import { URL } from "url"; - namespace Module {} + namespace Module { + /** + * Updates all the live bindings for builtin ES Modules to match the properties of the CommonJS exports. + * It does not add or remove exported names from the ES Modules. + */ + function syncBuiltinESMExports(): void; + + /** + * @experimental + */ + function findSourceMap(path: string, error?: Error): SourceMap; + interface SourceMapPayload { + file: string; + version: number; + sources: string[]; + sourcesContent: string[]; + names: string[]; + mappings: string; + sourceRoot: string; + } + + interface SourceMapping { + generatedLine: number; + generatedColumn: number; + originalSource: string; + originalLine: number; + originalColumn: number; + } + + /** + * @experimental + */ + class SourceMap { + readonly payload: SourceMapPayload; + constructor(payload: SourceMapPayload); + findEntry(line: number, column: number): SourceMapping; + } + } interface Module extends NodeModule {} class Module { static runMain(): void; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index a63d7aee5b..f9dcb5e19d 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -447,25 +447,6 @@ import * as trace_events from "trace_events"; tracing.disable(); } -///////////////////////////////////////////////////////// -/// stream tests : https://nodejs.org/api/stream.html /// -///////////////////////////////////////////////////////// -import stream = require('stream'); -import tty = require('tty'); - -{ - const writeStream = fs.createWriteStream('./index.d.ts'); - const _wom = writeStream.writableObjectMode; // $ExpectType boolean - - const readStream = fs.createReadStream('./index.d.ts'); - const _rom = readStream.readableObjectMode; // $ExpectType boolean - - const x: stream.Readable = process.stdin; - const stdin: tty.ReadStream = process.stdin; - const stdout: tty.WriteStream = process.stdout; - const stderr: tty.WriteStream = process.stderr; -} - //////////////////////////////////////////////////// /// Node.js ESNEXT Support //////////////////////////////////////////////////// diff --git a/types/node/test/fs.ts b/types/node/test/fs.ts index 8fac4f3749..9f7ca72a72 100644 --- a/types/node/test/fs.ts +++ b/types/node/test/fs.ts @@ -329,3 +329,11 @@ async function testPromisify() { bufferSize: 42, }); } + +{ + const writeStream = fs.createWriteStream('./index.d.ts'); + const _wom = writeStream.writableObjectMode; // $ExpectType boolean + + const readStream = fs.createReadStream('./index.d.ts'); + const _rom = readStream.readableObjectMode; // $ExpectType boolean +} diff --git a/types/node/test/module.ts b/types/node/test/module.ts index 721c668767..42328af8f5 100644 --- a/types/node/test/module.ts +++ b/types/node/test/module.ts @@ -42,3 +42,17 @@ const cachedModule2: Module = customRequire2.cache['/path/to/module.js']; const main1: Module | undefined = customRequire1.main; const main2: Module | undefined = customRequire2.main; + +Module.syncBuiltinESMExports(); + +const smap = new Module.SourceMap({ + file: 'test.js', + mappings: 'ASDASd', + names: [], + sourceRoot: '/', + sources: [], + version: 3, + sourcesContent: [], +}); +const pl: Module.SourceMapPayload = smap.payload; +const entry: Module.SourceMapping = smap.findEntry(1, 1); diff --git a/types/node/test/tty.ts b/types/node/test/tty.ts index 071b2c6a7d..c34824c72e 100644 --- a/types/node/test/tty.ts +++ b/types/node/test/tty.ts @@ -1,4 +1,5 @@ import * as tty from 'tty'; +import { Readable } from 'stream'; const rs: tty.ReadStream = new tty.ReadStream(0); const ws: tty.WriteStream = new tty.WriteStream(1); @@ -26,3 +27,8 @@ ws.getWindowSize(); const hasCOlors: boolean = ws.hasColors(); const isTTY: boolean = tty.isatty(1); + +const x: Readable = process.stdin; +const stdin: tty.ReadStream = process.stdin; +const stdout: tty.WriteStream = process.stdout; +const stderr: tty.WriteStream = process.stderr;