From b10b9a1da05dc882f818b5b50e592b4546d77fdc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 1 Sep 2020 13:00:08 -0700 Subject: [PATCH] Put current version of window-or-global in the root (#47208) * Put current version of window-or-global in the root Previously, the code that supports the oldest version of Typescript was in the root: 3.1 and below. Newer versions were in ts*/ subdirectories. This PR puts the newest version in the root, and older versions -- before 3.4 in this case -- in ts*/ subdirectories. This is possible because all supported versions of the Typescript now understand the typesVersions property in package.json. This PR needs a new version of DefinitelyTyped-tools and dtslint, which I will ship soon. It also needs to be brought up to date with master. * delete ts3.4 --- types/window-or-global/index.d.ts | 2 +- types/window-or-global/package.json | 4 ++-- types/window-or-global/ts3.3/index.d.ts | 4 ++++ types/window-or-global/{ts3.4 => ts3.3}/tsconfig.json | 0 types/window-or-global/{ts3.4 => ts3.3}/tslint.json | 0 .../window-or-global/ts3.3/window-or-global-tests.ts | 8 ++++++++ types/window-or-global/ts3.4/index.d.ts | 4 ---- .../window-or-global/ts3.4/window-or-global-tests.ts | 9 --------- types/window-or-global/window-or-global-tests.ts | 11 ++++++----- 9 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 types/window-or-global/ts3.3/index.d.ts rename types/window-or-global/{ts3.4 => ts3.3}/tsconfig.json (100%) rename types/window-or-global/{ts3.4 => ts3.3}/tslint.json (100%) create mode 100644 types/window-or-global/ts3.3/window-or-global-tests.ts delete mode 100644 types/window-or-global/ts3.4/index.d.ts delete mode 100644 types/window-or-global/ts3.4/window-or-global-tests.ts diff --git a/types/window-or-global/index.d.ts b/types/window-or-global/index.d.ts index 18f6f9550f..b395b7e9be 100644 --- a/types/window-or-global/index.d.ts +++ b/types/window-or-global/index.d.ts @@ -7,5 +7,5 @@ /// -declare const _: typeof self | typeof global; +declare const _: typeof globalThis & (typeof self | typeof global); export = _; diff --git a/types/window-or-global/package.json b/types/window-or-global/package.json index 29b70d48f4..b942445af8 100644 --- a/types/window-or-global/package.json +++ b/types/window-or-global/package.json @@ -2,9 +2,9 @@ "private": true, "types": "index", "typesVersions": { - ">=3.4.0-0": { + "<=3.3": { "*": [ - "ts3.4/*" + "ts3.3/*" ] } } diff --git a/types/window-or-global/ts3.3/index.d.ts b/types/window-or-global/ts3.3/index.d.ts new file mode 100644 index 0000000000..56b546377a --- /dev/null +++ b/types/window-or-global/ts3.3/index.d.ts @@ -0,0 +1,4 @@ +/// + +declare const _: typeof self | typeof global; +export = _; diff --git a/types/window-or-global/ts3.4/tsconfig.json b/types/window-or-global/ts3.3/tsconfig.json similarity index 100% rename from types/window-or-global/ts3.4/tsconfig.json rename to types/window-or-global/ts3.3/tsconfig.json diff --git a/types/window-or-global/ts3.4/tslint.json b/types/window-or-global/ts3.3/tslint.json similarity index 100% rename from types/window-or-global/ts3.4/tslint.json rename to types/window-or-global/ts3.3/tslint.json diff --git a/types/window-or-global/ts3.3/window-or-global-tests.ts b/types/window-or-global/ts3.3/window-or-global-tests.ts new file mode 100644 index 0000000000..f3d55a805a --- /dev/null +++ b/types/window-or-global/ts3.3/window-or-global-tests.ts @@ -0,0 +1,8 @@ +import * as root from "window-or-global"; + +if ('location' in root) { + const location: Location = root.location; + root.addEventListener("click", () => console.log("Hi!")); +} else { + const process: NodeJS.Process = root.process; +} diff --git a/types/window-or-global/ts3.4/index.d.ts b/types/window-or-global/ts3.4/index.d.ts deleted file mode 100644 index 8989d00ddf..0000000000 --- a/types/window-or-global/ts3.4/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -/// - -declare const _: typeof globalThis & (typeof self | typeof global); -export = _; diff --git a/types/window-or-global/ts3.4/window-or-global-tests.ts b/types/window-or-global/ts3.4/window-or-global-tests.ts deleted file mode 100644 index f1809c1b96..0000000000 --- a/types/window-or-global/ts3.4/window-or-global-tests.ts +++ /dev/null @@ -1,9 +0,0 @@ -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; -} diff --git a/types/window-or-global/window-or-global-tests.ts b/types/window-or-global/window-or-global-tests.ts index f3d55a805a..f1809c1b96 100644 --- a/types/window-or-global/window-or-global-tests.ts +++ b/types/window-or-global/window-or-global-tests.ts @@ -1,8 +1,9 @@ import * as root from "window-or-global"; -if ('location' in root) { - const location: Location = root.location; - root.addEventListener("click", () => console.log("Hi!")); -} else { - const process: NodeJS.Process = root.process; +if (Reflect.has(root, "location")) { + // $ExpectType Location + root.location; +} else if (Reflect.has(root, "process")) { + // $ExpectType Process + root.process; }