From 2120deba27a7c92a65d7784320f75a3577af0b40 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Wed, 21 Feb 2024 00:21:11 +0100 Subject: [PATCH 1/3] Move process.env type definition into src/types/ --- src/{ => types}/global.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{ => types}/global.d.ts (100%) diff --git a/src/global.d.ts b/src/types/global.d.ts similarity index 100% rename from src/global.d.ts rename to src/types/global.d.ts From a042266a1b09ab09082206f5223a6251ca2aa9b0 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Wed, 21 Feb 2024 01:08:57 +0100 Subject: [PATCH 2/3] Test process.env types --- src/types/global.typetest.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/types/global.typetest.tsx diff --git a/src/types/global.typetest.tsx b/src/types/global.typetest.tsx new file mode 100644 index 000000000..867c80381 --- /dev/null +++ b/src/types/global.typetest.tsx @@ -0,0 +1,10 @@ +export function ExpectEnvToHaveStrictType() { + process.env.REACT_APP_SHOW_BUILD_BANNERS = undefined + process.env.REACT_APP_SHOW_BUILD_BANNERS = 'true' + process.env.REACT_APP_API = 'https://' + + // @ts-expect-error Expect typescript to detect unsupported value + process.env.REACT_APP_SHOW_BUILD_BANNERS = 'unsupported_value' + // @ts-expect-error Expect typescript to detect required field + process.env.REACT_APP_API = undefined +} From 61a2e845628a33630e87e13874dddd53e689abad Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Wed, 21 Feb 2024 19:21:40 +0100 Subject: [PATCH 3/3] Fix process.env types --- .changelog/1277.trivial.md | 1 + src/types/global.d.ts | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .changelog/1277.trivial.md diff --git a/.changelog/1277.trivial.md b/.changelog/1277.trivial.md new file mode 100644 index 000000000..596506011 --- /dev/null +++ b/.changelog/1277.trivial.md @@ -0,0 +1 @@ +Test and fix process.env types diff --git a/src/types/global.d.ts b/src/types/global.d.ts index ac5ddfab9..cac3fc202 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -29,3 +29,5 @@ declare global { } } } + +export {}