Repository: remeda/remeda
Pull request #570 (2024-03-13 14:32:33)

feat(v2): bumping typescript target and library to es2022
Just doing this change and following up on any errors and warnings

codesandbox-ci[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/remeda/remeda/pr/570/builds/483244) or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e293d6c41566ca9f6e54f0e8319f415bd6c16aaf:

|Sandbox| Source |
|--|--|
|[remeda-example-vanilla](https://codesandbox.io/s/remeda-example-vanilla-sn3393)| Configuration |


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d8342c2..447cf7a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,13 +18,13 @@ jobs:
           - "~5.3.0"
           - "~5.2.0"
           - "~5.1.0"
-          # We use features that were added in v4.2 of typescript, so that is
-          # the lowest we can go here. This also means this is the lowest
-          # version we support. When this value changes in the future it needs
-          # to be communicated to the users.
-          - "~4.4.0"
-          - "~4.3.0"
-          - "~4.2.0"
+          # We use a target of ES2022 which was introduced in TypeScript v4.6,
+          # so that is the lowest we can go here. This also means this is the
+          # lowest version we support. When this value changes in the future it
+          # needs to be communicated to the users.
+          - "~4.8.0"
+          - "~4.7.0"
+          - "~4.6.0"
 
     steps:
       - name: ⬇️ Checkout repo
diff --git a/src/debounce.ts b/src/debounce.ts
index 2cfc1e8..04cc6d2 100644
--- a/src/debounce.ts
+++ b/src/debounce.ts
@@ -164,6 +164,7 @@ export function debounce<F extends (...args: any) => any>(
     latestCallArgs = undefined;
 
     // Invoke the function and store the results locally.
+    // @ts-expect-error [ts2488] - I'm not sure why typescript is having problem re-spreading the args array we got.
     result = func(...args);
   };
 
@@ -210,6 +211,7 @@ export function debounce<F extends (...args: any) => any>(
         } else {
           // Otherwise for "leading" and "both" the first call is actually
           // called directly and not via a timeout.
+          // @ts-expect-error [ts2488] - I'm not sure why typescript is having problem re-spreading the args array we got.
           result = func(...args);
         }
       } else {
diff --git a/tsconfig.dist.json b/tsconfig.dist.json
index 60da604..ff8a7f4 100644
--- a/tsconfig.dist.json
+++ b/tsconfig.dist.json
@@ -8,8 +8,8 @@
 
     "noEmit": true,
 
-    "target": "ES5",
-    "lib": ["ES6", "ES2017.Object", "DOM", "DOM.Iterable"],
+    "target": "ES2022",
+    "lib": ["ES2022", "DOM"],
 
     "skipDefaultLibCheck": false,
     "skipLibCheck": false
diff --git a/tsconfig.json b/tsconfig.json
index 7115edf..8a02b02 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -33,12 +33,8 @@
     "isolatedModules": true,
 
     // LANGUAGE and ENVIRONMENT
-    // TODO: The recommended target is ES2015 (ES6). Node10 supports es2018 and
-    // the vast majority of browsers are probably above that too already. It's
-    // most likely safe to up this value, and it would probably result in a
-    // smaller package size.
-    "target": "ES5",
-    "lib": ["ES6", "ES2017.Object", "DOM", "DOM.Iterable"],
+    "target": "ES2022",
+    "lib": ["ES2022", "DOM"],
 
     // COMPLETENESS
     "skipLibCheck": true


Test patch:
diff --git a/src/join.test.ts b/src/join.test.ts
index ceee533..f69c46e 100644
--- a/src/join.test.ts
+++ b/src/join.test.ts
@@ -15,7 +15,6 @@ describe("at runtime", () => {
     });
 
     it("bigint", () => {
-      // @ts-expect-error [ts2737] - Our target is too low to use bigints but our runtimes support them so we want to test them too
       const array = [1n, 2n, 3n, 4n, 5n];
       const result = join(array, ",");
       expect(result).toEqual("1,2,3,4,5");
@@ -41,7 +40,6 @@ describe("at runtime", () => {
   });
 
   it("joins different-typed items", () => {
-    // @ts-expect-error [ts2737] - Our target is too low to use bigints but our runtimes support them so we want to test them too
     const array = [1, "2", 3n, true, null, undefined];
     const result = join(array, ",");
     expect(result).toEqual("1,2,3,true,,");
@@ -147,7 +145,6 @@ describe("typing", () => {
     });
 
     it("bigint", () => {
-      // @ts-expect-error [ts2737] - Our target is too low to use bigints but our runtimes support them so we want to test them too
       const array: [bigint, bigint] = [1n, 2n];
       const result = join(array, ",");
       expectTypeOf(result).toEqualTypeOf<`${bigint},${bigint}`>();