Skip to content
Merged
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
1 change: 1 addition & 0 deletions types/node/globals.global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var global: NodeJS.Global;
6 changes: 5 additions & 1 deletion types/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
// Surasak Chaisurin <https://github.com/Ryan-Willpower>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Anna Henningsen <https://github.com/addaleax>
// Jason Kwok <https://github.com/JasonHK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// NOTE: These definitions support NodeJS and TypeScript 3.5.
Expand All @@ -59,7 +60,10 @@
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="base.d.ts" />

// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in +ts3.7
// We can't include globals.global.d.ts in globals.d.ts, as it'll cause duplication errors in TypeScript 3.5+
/// <reference path="globals.global.d.ts" />

// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in TypeScript 3.7+
/// <reference path="assert.d.ts" />

// Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`)
Expand Down
2 changes: 1 addition & 1 deletion types/node/ts3.2/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
// - ~/ts3.2/base.d.ts - Definitions specific to TypeScript 3.2
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with assert pulled in
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with global and assert pulled in

// Reference required types from the default lib:
/// <reference lib="es2018" />
Expand Down
4 changes: 4 additions & 0 deletions types/node/ts3.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.
// This is requried to enable globalThis support for global in ts3.5 without causing errors
// This is requried to enable typing assert in ts3.7 without causing errors
// Typically type modifiations should be made in base.d.ts instead of here

/// <reference path="base.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../assert.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../globals.global.d.ts" />
3 changes: 3 additions & 0 deletions types/node/ts3.5/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/base.d.ts" />

// TypeScript 3.5-specific augmentations:
/// <reference path="globals.global.d.ts" />

// TypeScript 3.5-specific augmentations:
/// <reference path="wasi.d.ts" />
1 change: 1 addition & 0 deletions types/node/ts3.5/globals.global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var global: NodeJS.Global & typeof globalThis;
12 changes: 12 additions & 0 deletions types/node/ts3.5/test/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//////////////////////////////////////////////////////////////////////////
/// `globalThis` Tests: https://node.green/#ES2020-features-globalThis ///
//////////////////////////////////////////////////////////////////////////

{
const isGlobal: NodeJS.Global = global;
const isGlobalThis: typeof globalThis = global;

const accessibleToGlobalThisMembers: true = global.RANDOM_GLOBAL_VARIABLE;
}

declare var RANDOM_GLOBAL_VARIABLE: true;
3 changes: 2 additions & 1 deletion types/node/ts3.5/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"files": [
"index.d.ts",
"node-tests.ts"
"node-tests.ts",
"test/globals.ts"
],
"compilerOptions": {
"module": "commonjs",
Expand Down
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
1 change: 1 addition & 0 deletions types/node/v12/globals.global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var global: NodeJS.Global;
6 changes: 5 additions & 1 deletion types/node/v12/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 @@ -57,7 +58,10 @@
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="base.d.ts" />

// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in +ts3.7
// We can't include globals.global.d.ts in globals.d.ts, as it'll cause duplication errors in TypeScript 3.4+
/// <reference path="globals.global.d.ts" />

// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in TypeScript 3.7+
/// <reference path="assert.d.ts" />

// TypeScript 2.1-specific augmentations:
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 @@ -7,6 +7,11 @@
"ts3.7/*"
]
},
">=3.4.0-0": {
"*": [
"ts3.4/*"
]
},
">=3.2.0-0": {
"*": [
"ts3.2/*"
Expand Down
2 changes: 1 addition & 1 deletion types/node/v12/ts3.2/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
// - ~/ts3.2/base.d.ts - Definitions specific to TypeScript 3.2
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with assert pulled in
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with global and assert pulled in

// Reference required types from the default lib:
/// <reference lib="es2018" />
Expand Down
4 changes: 4 additions & 0 deletions types/node/v12/ts3.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.
// This is requried to enable globalThis support for global in ts3.4 without causing errors
// This is requried to enable typing assert in ts3.7 without causing errors
// Typically type modifiations should be made in base.d.ts instead of here

/// <reference path="base.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../assert.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../globals.global.d.ts" />
20 changes: 20 additions & 0 deletions types/node/v12/ts3.4/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// NOTE: These definitions support NodeJS and TypeScript 3.4.

// 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.1
// - ~/ts3.4/base.d.ts - Definitions specific to TypeScript 3.4
// - ~/ts3.4/index.d.ts - Definitions specific to TypeScript 3.4 with assert pulled in

// 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/base.d.ts" />

// TypeScript 3.5-specific augmentations:
/// <reference path="globals.global.d.ts" />
1 change: 1 addition & 0 deletions types/node/v12/ts3.4/globals.global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var global: NodeJS.Global & typeof globalThis;
8 changes: 8 additions & 0 deletions types/node/v12/ts3.4/index.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.
// This is requried to enable typing assert in ts3.7 without causing errors
// Typically type modifiations should be made in base.d.ts instead of here

/// <reference path="base.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../assert.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;
12 changes: 12 additions & 0 deletions types/node/v12/ts3.4/test/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//////////////////////////////////////////////////////////////////////////
/// `globalThis` Tests: https://node.green/#ES2020-features-globalThis ///
//////////////////////////////////////////////////////////////////////////

{
const isGlobal: NodeJS.Global = global;
const isGlobalThis: typeof globalThis = global;

const accessibleToGlobalThisMembers: true = global.RANDOM_GLOBAL_VARIABLE;
}

declare var RANDOM_GLOBAL_VARIABLE: true;
31 changes: 31 additions & 0 deletions types/node/v12/ts3.4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"files": [
"index.d.ts",
"node-tests.ts",
"test/globals.ts"
],
"compilerOptions": {
"module": "commonjs",
"target": "esnext",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../../",
"typeRoots": [
"../../../"
],
"paths": {
"node": [
"node/v12"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
1 change: 1 addition & 0 deletions types/node/v12/ts3.4/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
2 changes: 1 addition & 1 deletion types/node/v12/ts3.7/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// 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" />
/// <reference path="../ts3.4/base.d.ts" />

// TypeScript 3.7-specific augmentations:
/// <reference path="assert.d.ts" />
1 change: 0 additions & 1 deletion types/node/v13/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
1 change: 1 addition & 0 deletions types/node/v13/globals.global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var global: NodeJS.Global;
6 changes: 5 additions & 1 deletion types/node/v13/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
// 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.
Expand All @@ -59,7 +60,10 @@
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="base.d.ts" />

// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in +ts3.7
// We can't include globals.global.d.ts in globals.d.ts, as it'll cause duplication errors in TypeScript 3.5+
/// <reference path="globals.global.d.ts" />

// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in TypeScript 3.7+
/// <reference path="assert.d.ts" />

// Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`)
Expand Down
2 changes: 1 addition & 1 deletion types/node/v13/ts3.2/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
// - ~/ts3.2/base.d.ts - Definitions specific to TypeScript 3.2
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with assert pulled in
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with global and assert pulled in

// Reference required types from the default lib:
/// <reference lib="es2018" />
Expand Down
4 changes: 4 additions & 0 deletions types/node/v13/ts3.2/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// NOTE: These definitions support NodeJS and TypeScript 3.2.
// This is requried to enable globalThis support for global in ts3.5 without causing errors
// This is requried to enable typing assert in ts3.7 without causing errors
// Typically type modifiations should be made in base.d.ts instead of here

/// <reference path="base.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../assert.d.ts" />

// tslint:disable-next-line:no-bad-reference
/// <reference path="../globals.global.d.ts" />
3 changes: 3 additions & 0 deletions types/node/v13/ts3.5/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
// tslint:disable-next-line:no-bad-reference
/// <reference path="../ts3.2/base.d.ts" />

// TypeScript 3.4-specific augmentations:
/// <reference path="globals.global.d.ts" />

// TypeScript 3.5-specific augmentations:
/// <reference path="wasi.d.ts" />
1 change: 1 addition & 0 deletions types/node/v13/ts3.5/globals.global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var global: NodeJS.Global & typeof globalThis;
12 changes: 12 additions & 0 deletions types/node/v13/ts3.5/test/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//////////////////////////////////////////////////////////////////////////
/// `globalThis` Tests: https://node.green/#ES2020-features-globalThis ///
//////////////////////////////////////////////////////////////////////////

{
const isGlobal: NodeJS.Global = global;
const isGlobalThis: typeof globalThis = global;

const accessibleToGlobalThisMembers: true = global.RANDOM_GLOBAL_VARIABLE;
}

declare var RANDOM_GLOBAL_VARIABLE: true;
3 changes: 2 additions & 1 deletion types/node/v13/ts3.5/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"files": [
"index.d.ts",
"node-tests.ts"
"node-tests.ts",
"test/globals.ts"
],
"compilerOptions": {
"module": "commonjs",
Expand Down
4 changes: 3 additions & 1 deletion types/window-or-global/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Type definitions for window-or-global 1.0
// Project: https://github.com/purposeindustries/window-or-global
// Definitions by: vvakame <https://github.com/vvakame>
// Jason Kwok <https://github.com/JasonHK>
// ExE Boss <https://github.com/ExE-Boss>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

declare var _: Window | typeof global;
declare const _: typeof self | typeof global;
export = _;
11 changes: 11 additions & 0 deletions types/window-or-global/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"types": "index",
"typesVersions": {
">=3.4.0-0": {
"*": [
"ts3.4/*"
]
}
}
}
4 changes: 4 additions & 0 deletions types/window-or-global/ts3.4/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference types="node" />

declare const _: typeof globalThis & (typeof self | typeof global);
export = _;
25 changes: 25 additions & 0 deletions types/window-or-global/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",
"window-or-global-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/window-or-global/ts3.4/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
9 changes: 9 additions & 0 deletions types/window-or-global/ts3.4/window-or-global-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as root from "window-or-global";

if (Reflect.has(root, "location")) {
// $ExpectType Location
root.location;
} else if (Reflect.has(root, "process")) {
// $ExpectType Process
root.process;
}