Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion types/node/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ interface RequireResolve extends NodeJS.RequireResolve {}
interface NodeModule extends NodeJS.Module {}

declare var process: NodeJS.Process;
declare var global: NodeJS.Global;
declare var console: Console;

declare var __filename: string;
Expand Down
6 changes: 6 additions & 0 deletions types/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@
// ExE Boss <https://github.com/ExE-Boss>
// Surasak Chaisurin <https://github.com/Ryan-Willpower>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Jason Kwok <https://github.com/JasonHK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// NOTE: These definitions support NodeJS and TypeScript 3.5.

// NOTE: TypeScript version-specific augmentations can be found in the following paths:
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
// - ~/index.d.ts - Definitions specific to TypeScript 2.8
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2
Copy link
Contributor

Choose a reason for hiding this comment

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

this lines looks dangerous for me. There are many options for node.js version, what we support.
This changes also add complexity for typescript version. As a result we have a matrix, what is too bit.

Copy link
Contributor Author

@JasonHK JasonHK Mar 22, 2020

Choose a reason for hiding this comment

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

@galkin Actually, "~/ts3.2" already exists before this pull request, it's just missing from that comment.

Also, the approach I used here is the result of TypeScript error TS2403, this error makes me unable to simply override global.

// - ~/ts3.4/index.d.ts - Definitions specific to TypeScript 3.4
// - ~/ts3.5/index.d.ts - Definitions specific to TypeScript 3.5

// NOTE: Augmentations for TypeScript 3.5 and later should use individual files for overrides
Expand All @@ -60,6 +63,9 @@
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="base.d.ts" />

// This needs to be in ~/index.d.ts to avoid TS2403
declare var global: NodeJS.Global;

// Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`)
// Empty interfaces are used here which merge fine with the real declarations in the lib XXX files
// just to ensure the names are known and node typings can be used without importing these libs.
Expand Down
8 changes: 2 additions & 6 deletions types/node/node-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,14 @@ import * as trace_events from "trace_events";
console.warn('message', 'foo', 'bar');

// --- Inspector mode only ---
console.markTimeline();
console.markTimeline('label');
// `console.markTimeline()`, `console.timeline()` and `console.timelineEnd()` were removed since
// TypeScript v3.9.0-dev.20200319.
console.profile();
console.profile('label');
console.profileEnd();
console.profileEnd('label');
console.timeStamp();
console.timeStamp('label');
console.timeline();
console.timeline('label');
console.timelineEnd();
console.timelineEnd('label');
}
}

Expand Down
5 changes: 5 additions & 0 deletions types/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"ts3.5/*"
]
},
">=3.4.0-0": {
"*": [
"ts3.4/*"
]
},
">=3.2.0-0": {
"*": [
"ts3.2/*"
Expand Down
16 changes: 16 additions & 0 deletions types/node/ts3.2/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.

// Reference required types from the default lib:
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../base.d.ts" />

// TypeScript 3.2-specific augmentations:
/// <reference path="fs.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="globals.d.ts" />
15 changes: 3 additions & 12 deletions types/node/ts3.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.

// Reference required types from the default lib:
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../base.d.ts" />
/// <reference path="base.d.ts" />

// TypeScript 3.2-specific augmentations:
/// <reference path="fs.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="globals.d.ts" />
// This needs to be in ~/ts3.2/index.d.ts to avoid TS2403
declare var global: NodeJS.Global;
8 changes: 8 additions & 0 deletions types/node/ts3.4/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// NOTE: These definitions support NodeJS and TypeScript 3.4 or up.

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/base.d.ts" />

// TypeScript 3.4-specific augmentations:
/// <reference path="globals.d.ts" />
4 changes: 4 additions & 0 deletions types/node/ts3.4/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/globals.d.ts" />

declare var global: NodeJS.Global & typeof globalThis;
4 changes: 4 additions & 0 deletions types/node/ts3.4/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// NOTE: These definitions support NodeJS and TypeScript 3.4

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="base.d.ts" />
6 changes: 6 additions & 0 deletions types/node/ts3.4/node-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//////////////////////////////////////////////////////////////////////////
/// `globalThis` Tests: https://node.green/#ES2020-features-globalThis ///
//////////////////////////////////////////////////////////////////////////

const isGlobal: NodeJS.Global = global;
const isGlobalThis: typeof globalThis = global;
25 changes: 25 additions & 0 deletions types/node/ts3.4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "esnext",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"node-tests.ts"
]
}
6 changes: 6 additions & 0 deletions types/node/ts3.4/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-single-declare-module": false
}
}
10 changes: 10 additions & 0 deletions types/node/ts3.5/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// NOTE: These definitions support NodeJS and TypeScript 3.5.

// Reference required types from the default lib:

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.4/base.d.ts" />

// TypeScript 3.5-specific augmentations:
/// <reference path="wasi.d.ts" />
12 changes: 1 addition & 11 deletions types/node/ts3.5/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
// NOTE: These definitions support NodeJS and TypeScript 3.5.

// Reference required types from the default lib:
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/index.d.ts" />

// TypeScript 3.5-specific augmentations:
/// <reference path="wasi.d.ts" />
/// <reference path="base.d.ts" />
1 change: 0 additions & 1 deletion types/node/v12/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ interface ImportMeta {
* *
------------------------------------------------*/
declare var process: NodeJS.Process;
declare var global: NodeJS.Global;
declare var console: Console;

declare var __filename: string;
Expand Down
4 changes: 4 additions & 0 deletions types/node/v12/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
// Junxiao Shi <https://github.com/yoursunny>
// Ilia Baryshnikov <https://github.com/qwelias>
// ExE Boss <https://github.com/ExE-Boss>
// Jason Kwok <https://github.com/JasonHK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// NOTE: These definitions support NodeJS and TypeScript 3.2.
Expand All @@ -60,6 +61,9 @@

// TypeScript 2.1-specific augmentations:

// This needs to be in ~/index.d.ts to avoid TS2403
declare var global: NodeJS.Global;

// Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`)
// Empty interfaces are used here which merge fine with the real declarations in the lib XXX files
// just to ensure the names are known and node typings can be used without importing these libs.
Expand Down
5 changes: 5 additions & 0 deletions types/node/v12/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"*": [
"ts3.2/*"
]
},
">=3.4.0-0": {
"*": [
"ts3.4/*"
]
}
}
}
16 changes: 16 additions & 0 deletions types/node/v12/ts3.2/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.

// Reference required types from the default lib:
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../base.d.ts" />

// TypeScript 3.2-specific augmentations:
/// <reference path="fs.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="globals.d.ts" />
15 changes: 3 additions & 12 deletions types/node/v12/ts3.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.

// Reference required types from the default lib:
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../base.d.ts" />
/// <reference path="base.d.ts" />

// TypeScript 3.2-specific augmentations:
/// <reference path="fs.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="globals.d.ts" />
// This needs to be in ~/ts3.2/index.d.ts to avoid TS2403
declare var global: NodeJS.Global;
8 changes: 8 additions & 0 deletions types/node/v12/ts3.4/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// NOTE: These definitions support NodeJS and TypeScript 3.4 or up.

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/base.d.ts" />

// TypeScript 3.4-specific augmentations:
/// <reference path="globals.d.ts" />
4 changes: 4 additions & 0 deletions types/node/v12/ts3.4/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/globals.d.ts" />

declare var global: NodeJS.Global & typeof globalThis;
4 changes: 4 additions & 0 deletions types/node/v12/ts3.4/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// NOTE: These definitions support NodeJS and TypeScript 3.4

// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="base.d.ts" />
6 changes: 6 additions & 0 deletions types/node/v12/ts3.4/node-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//////////////////////////////////////////////////////////////////////////
/// `globalThis` Tests: https://node.green/#ES2020-features-globalThis ///
//////////////////////////////////////////////////////////////////////////

const isGlobal: NodeJS.Global = global;
const isGlobalThis: typeof globalThis = global;
28 changes: 28 additions & 0 deletions types/node/v12/ts3.4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "esnext",
"lib": [
"es6",
"dom"
],
"paths": {
"node": ["node/v12"]
},
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../../",
"typeRoots": [
"../../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"node-tests.ts"
]
}
6 changes: 6 additions & 0 deletions types/node/v12/ts3.4/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-single-declare-module": false
}
}