From f350dd9f2efee37487fccc3b962ba7f0c66e2e2a Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sat, 6 Mar 2021 14:29:19 +0900 Subject: [PATCH 1/6] feat(jest): Add ./global-types as an alias to ./index --- types/jest/global-types.d.ts | 11 +++++++++++ types/jest/tsconfig.json | 1 + 2 files changed, 12 insertions(+) create mode 100644 types/jest/global-types.d.ts diff --git a/types/jest/global-types.d.ts b/types/jest/global-types.d.ts new file mode 100644 index 00000000000000..f0eccd3f5e51ef --- /dev/null +++ b/types/jest/global-types.d.ts @@ -0,0 +1,11 @@ +// Starting from jest v24.3.0, the jest package provides its own type definition. +// @types/jest now serves a different purpose than that; +// it declares global variables injeced by jest, rather than jest's own API. +// +// Unfortunately, that led to `types: ["jest"]` being resolved to the jest package, +// causing problems when `typeRoots` is configured. +// +// This file enables users to specify `types: ["jest/global-types"]` in tsconfig.json +// to clarify their intention. + +import "./index"; diff --git a/types/jest/tsconfig.json b/types/jest/tsconfig.json index c922017ac11689..58960b94d9d9b6 100644 --- a/types/jest/tsconfig.json +++ b/types/jest/tsconfig.json @@ -17,6 +17,7 @@ }, "files": [ "index.d.ts", + "global-types.d.ts", "jest-tests.ts" ] } From 792048705192d694278b997bff8568240d7c2159 Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sat, 6 Mar 2021 14:42:47 +0900 Subject: [PATCH 2/6] Add tests for jest/global-types --- types/jest/test/global-types-tests.ts | 5 +++++ types/jest/tsconfig.json | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 types/jest/test/global-types-tests.ts diff --git a/types/jest/test/global-types-tests.ts b/types/jest/test/global-types-tests.ts new file mode 100644 index 00000000000000..9143010fccada6 --- /dev/null +++ b/types/jest/test/global-types-tests.ts @@ -0,0 +1,5 @@ +import "./global-types"; + +describe("42", () => { + expect(42).toBe(42); +}); diff --git a/types/jest/tsconfig.json b/types/jest/tsconfig.json index 58960b94d9d9b6..c4e7702e74f9e8 100644 --- a/types/jest/tsconfig.json +++ b/types/jest/tsconfig.json @@ -18,6 +18,7 @@ "files": [ "index.d.ts", "global-types.d.ts", - "jest-tests.ts" + "jest-tests.ts", + "test/global-types-tests.ts" ] } From 0fcd84e9c6dcc5a9e86aa9187c562b22c75141ea Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sat, 6 Mar 2021 14:44:32 +0900 Subject: [PATCH 3/6] Add global-types.d.ts to OTHER_FILES.txt --- types/jest/OTHER_FILES.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 types/jest/OTHER_FILES.txt diff --git a/types/jest/OTHER_FILES.txt b/types/jest/OTHER_FILES.txt new file mode 100644 index 00000000000000..97d6772ab91104 --- /dev/null +++ b/types/jest/OTHER_FILES.txt @@ -0,0 +1 @@ +global-types.d.ts From bc106a5434ef2a62c2e27ab89ce99a0479d71c85 Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sat, 6 Mar 2021 14:47:58 +0900 Subject: [PATCH 4/6] Remove global-types.d.ts from tsconfig --- types/jest/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/jest/tsconfig.json b/types/jest/tsconfig.json index c4e7702e74f9e8..f701d50befbaa8 100644 --- a/types/jest/tsconfig.json +++ b/types/jest/tsconfig.json @@ -17,7 +17,6 @@ }, "files": [ "index.d.ts", - "global-types.d.ts", "jest-tests.ts", "test/global-types-tests.ts" ] From 4ef76c57b20037bdb28fe199039bbfbb8022da06 Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sun, 7 Mar 2021 13:23:41 +0900 Subject: [PATCH 5/6] Adjust file list --- types/jest/OTHER_FILES.txt | 1 - types/jest/tsconfig.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 types/jest/OTHER_FILES.txt diff --git a/types/jest/OTHER_FILES.txt b/types/jest/OTHER_FILES.txt deleted file mode 100644 index 97d6772ab91104..00000000000000 --- a/types/jest/OTHER_FILES.txt +++ /dev/null @@ -1 +0,0 @@ -global-types.d.ts diff --git a/types/jest/tsconfig.json b/types/jest/tsconfig.json index f701d50befbaa8..c4e7702e74f9e8 100644 --- a/types/jest/tsconfig.json +++ b/types/jest/tsconfig.json @@ -17,6 +17,7 @@ }, "files": [ "index.d.ts", + "global-types.d.ts", "jest-tests.ts", "test/global-types-tests.ts" ] From 614b1fd722239dbcc99d3e8223f2bd79fd0a502c Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sun, 7 Mar 2021 13:23:51 +0900 Subject: [PATCH 6/6] Use --- types/jest/global-types.d.ts | 2 +- types/jest/test/global-types-tests.ts | 2 +- types/jest/tslint.json | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/types/jest/global-types.d.ts b/types/jest/global-types.d.ts index f0eccd3f5e51ef..af7642413de938 100644 --- a/types/jest/global-types.d.ts +++ b/types/jest/global-types.d.ts @@ -8,4 +8,4 @@ // This file enables users to specify `types: ["jest/global-types"]` in tsconfig.json // to clarify their intention. -import "./index"; +/// diff --git a/types/jest/test/global-types-tests.ts b/types/jest/test/global-types-tests.ts index 9143010fccada6..69b2cee3bd2d50 100644 --- a/types/jest/test/global-types-tests.ts +++ b/types/jest/test/global-types-tests.ts @@ -1,4 +1,4 @@ -import "./global-types"; +/// describe("42", () => { expect(42).toBe(42); diff --git a/types/jest/tslint.json b/types/jest/tslint.json index 3db14f85eaf7b9..56086bb86abffb 100644 --- a/types/jest/tslint.json +++ b/types/jest/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-bad-reference": false + } +}