From c0c3e0280c6790a050d2f526d3d6c3d47cb7f512 Mon Sep 17 00:00:00 2001 From: Kylor Hall Date: Sun, 5 Dec 2021 09:33:03 +1300 Subject: [PATCH 1/4] Create a `types/index.d.ts` to import `global.d.ts` and add another test scenario. The resolution just appears we're using typeRoots incorrectly! See comment: https://github.com/gustavopch/tsc-files/pull/22#issuecomment-986079947 --- types/index.d.ts | 2 ++ types/other.d.ts | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 types/index.d.ts create mode 100644 types/other.d.ts diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..bff6b8d --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,2 @@ +import './global'; +import './other'; diff --git a/types/other.d.ts b/types/other.d.ts new file mode 100644 index 0000000..5ea9563 --- /dev/null +++ b/types/other.d.ts @@ -0,0 +1,2 @@ +/** Just assume this is some globally available variable. */ +declare const OTHER_GLOBAL_TYPE = true; From db296a300c3e724af4d8ca5c91ea76acd4b986d9 Mon Sep 17 00:00:00 2001 From: Kylor Hall Date: Sun, 5 Dec 2021 09:33:11 +1300 Subject: [PATCH 2/4] Add another test case. --- src/file.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/file.ts b/src/file.ts index 1acf412..2db6b97 100644 --- a/src/file.ts +++ b/src/file.ts @@ -3,3 +3,7 @@ console.log(`In environment: ${GLOBAL_SETTINGS.ENV}`); if (GLOBAL_SETTINGS.DEBUG) { console.debug('Debug enabled'); } + +if (OTHER_GLOBAL_TYPE) { + console.debug('Other global enabled'); +} From b4e062924ba5ff4b34579a2735ddf8c7b6cff76d Mon Sep 17 00:00:00 2001 From: Kylor Hall Date: Sun, 5 Dec 2021 09:45:05 +1300 Subject: [PATCH 3/4] =?UTF-8?q?Move=20these=20files=20around=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/{global.d.ts => global/index.d.ts} | 3 +++ types/index.d.ts | 2 -- types/other.d.ts | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) rename types/{global.d.ts => global/index.d.ts} (63%) delete mode 100644 types/index.d.ts delete mode 100644 types/other.d.ts diff --git a/types/global.d.ts b/types/global/index.d.ts similarity index 63% rename from types/global.d.ts rename to types/global/index.d.ts index 10bf21d..da2ce08 100644 --- a/types/global.d.ts +++ b/types/global/index.d.ts @@ -1,3 +1,6 @@ +/** Just assume this is some globally available variable. */ +declare const OTHER_GLOBAL_TYPE = true; + /** Just assume this is some globally available variable. */ declare const GLOBAL_SETTINGS: { ENV: 'development' | 'production'; diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index bff6b8d..0000000 --- a/types/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import './global'; -import './other'; diff --git a/types/other.d.ts b/types/other.d.ts deleted file mode 100644 index 5ea9563..0000000 --- a/types/other.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/** Just assume this is some globally available variable. */ -declare const OTHER_GLOBAL_TYPE = true; From f46482460dacc82d1bec79ba2c100d742a5c2030 Mon Sep 17 00:00:00 2001 From: Kylor Hall Date: Sun, 5 Dec 2021 09:45:27 +1300 Subject: [PATCH 4/4] Test to ensure this works. --- src/file.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/file.ts b/src/file.ts index 2db6b97..c37172f 100644 --- a/src/file.ts +++ b/src/file.ts @@ -1,7 +1,7 @@ console.log(`In environment: ${GLOBAL_SETTINGS.ENV}`); if (GLOBAL_SETTINGS.DEBUG) { - console.debug('Debug enabled'); + console.debug('Debug enabled??'); } if (OTHER_GLOBAL_TYPE) {