From b29655fecac7e1f95d5524de16a08a22b0bf4299 Mon Sep 17 00:00:00 2001
From: Bailey Pearson <bailey.pearson@mongodb.com>
Date: Tue, 16 Jul 2024 10:53:29 -0600
Subject: [PATCH] finish merge

---
 .evergreen/config.yml                  | 61 ++++++++++----------------
 .evergreen/generate_evergreen_tasks.js | 10 +++--
 .evergreen/run-typescript.sh           |  7 ++-
 3 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/.evergreen/config.yml b/.evergreen/config.yml
index b6f9f6176bc..5252f3842c7 100644
--- a/.evergreen/config.yml
+++ b/.evergreen/config.yml
@@ -3453,7 +3453,7 @@ tasks:
             - {key: NPM_VERSION, value: '9'}
       - func: install dependencies
       - func: run lint checks
-  - name: check-types-typescript-next-node-types-20.12.7
+  - name: check-types-typescript-next-node-types-20.14.10
     tags:
       - check-types-typescript-next
       - typescript-compilation
@@ -3465,12 +3465,12 @@ tasks:
             - {key: NODE_LTS_VERSION, value: '16'}
             - {key: NPM_VERSION, value: '9'}
             - {key: TS_VERSION, value: next}
-            - {key: TYPES_VERSION, value: 20.12.7}
+            - {key: TYPES_VERSION, value: 20.14.10}
       - func: install dependencies
       - func: check types
-  - name: compile-driver-typescript-current-node-types-20.12.7
+  - name: check-types-typescript-current-node-types-20.14.10
     tags:
-      - compile-driver-typescript-current
+      - check-types-typescript-current
       - typescript-compilation
     commands:
       - command: expansions.update
@@ -3480,12 +3480,12 @@ tasks:
             - {key: NODE_LTS_VERSION, value: '16'}
             - {key: NPM_VERSION, value: '9'}
             - {key: TS_VERSION, value: current}
-            - {key: TYPES_VERSION, value: 20.12.7}
+            - {key: TYPES_VERSION, value: 20.14.10}
       - func: install dependencies
-      - func: compile driver
-  - name: check-types-typescript-current-node-types-20.12.7
+      - func: check types
+  - name: check-types-typescript-next-node-types-16.x
     tags:
-      - check-types-typescript-current
+      - check-types-typescript-next
       - typescript-compilation
     commands:
       - command: expansions.update
@@ -3494,13 +3494,13 @@ tasks:
           updates:
             - {key: NODE_LTS_VERSION, value: '16'}
             - {key: NPM_VERSION, value: '9'}
-            - {key: TS_VERSION, value: current}
-            - {key: TYPES_VERSION, value: 20.12.7}
+            - {key: TS_VERSION, value: next}
+            - {key: TYPES_VERSION, value: 16.x}
       - func: install dependencies
       - func: check types
-  - name: check-types-typescript-4.4-node-types-20.12.7
+  - name: check-types-typescript-current-node-types-16.x
     tags:
-      - check-types-typescript-4.4
+      - check-types-typescript-current
       - typescript-compilation
     commands:
       - command: expansions.update
@@ -3509,13 +3509,13 @@ tasks:
           updates:
             - {key: NODE_LTS_VERSION, value: '16'}
             - {key: NPM_VERSION, value: '9'}
-            - {key: TS_VERSION, value: '4.4'}
-            - {key: TYPES_VERSION, value: 20.12.7}
+            - {key: TS_VERSION, value: current}
+            - {key: TYPES_VERSION, value: 16.x}
       - func: install dependencies
       - func: check types
-  - name: check-types-typescript-next-node-types-16.x
+  - name: check-types-typescript-4.4-node-types-18.11.9
     tags:
-      - check-types-typescript-next
+      - check-types-typescript-4.4
       - typescript-compilation
     commands:
       - command: expansions.update
@@ -3524,11 +3524,11 @@ tasks:
           updates:
             - {key: NODE_LTS_VERSION, value: '16'}
             - {key: NPM_VERSION, value: '9'}
-            - {key: TS_VERSION, value: next}
-            - {key: TYPES_VERSION, value: 16.x}
+            - {key: TS_VERSION, value: '4.4'}
+            - {key: TYPES_VERSION, value: 18.11.9}
       - func: install dependencies
       - func: check types
-  - name: compile-driver-typescript-current-node-types-16.x
+  - name: compile-driver-typescript-current-node-types-20.14.10
     tags:
       - compile-driver-typescript-current
       - typescript-compilation
@@ -3540,12 +3540,12 @@ tasks:
             - {key: NODE_LTS_VERSION, value: '16'}
             - {key: NPM_VERSION, value: '9'}
             - {key: TS_VERSION, value: current}
-            - {key: TYPES_VERSION, value: 16.x}
+            - {key: TYPES_VERSION, value: 20.14.10}
       - func: install dependencies
       - func: compile driver
-  - name: check-types-typescript-current-node-types-16.x
+  - name: compile-driver-typescript-current-node-types-16.x
     tags:
-      - check-types-typescript-current
+      - compile-driver-typescript-current
       - typescript-compilation
     commands:
       - command: expansions.update
@@ -3557,22 +3557,7 @@ tasks:
             - {key: TS_VERSION, value: current}
             - {key: TYPES_VERSION, value: 16.x}
       - func: install dependencies
-      - func: check types
-  - name: check-types-typescript-4.4-node-types-16.x
-    tags:
-      - check-types-typescript-4.4
-      - typescript-compilation
-    commands:
-      - command: expansions.update
-        type: setup
-        params:
-          updates:
-            - {key: NODE_LTS_VERSION, value: '16'}
-            - {key: NPM_VERSION, value: '9'}
-            - {key: TS_VERSION, value: '4.4'}
-            - {key: TYPES_VERSION, value: 16.x}
-      - func: install dependencies
-      - func: check types
+      - func: compile driver
   - name: download-and-merge-coverage
     tags: []
     commands:
diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js
index 9b27a7dd78b..8af511a8f5a 100644
--- a/.evergreen/generate_evergreen_tasks.js
+++ b/.evergreen/generate_evergreen_tasks.js
@@ -532,14 +532,16 @@ function* makeTypescriptTasks() {
 
   const typesVersion = require('../package.json').devDependencies['@types/node'].slice(1)
   yield makeCheckTypesTask('next', typesVersion);
-  yield makeCompileTask('current', typesVersion);
   yield makeCheckTypesTask('current', typesVersion);
-  yield makeCheckTypesTask('4.4', typesVersion);
 
   yield makeCheckTypesTask('next', '16.x');
-  yield makeCompileTask('current', '16.x');
   yield makeCheckTypesTask('current', '16.x');
-  yield makeCheckTypesTask('4.4', '16.x');
+
+  // typescript 4.4 only compiles our types with this particular version
+  yield makeCheckTypesTask('4.4', '18.11.9');
+
+  yield makeCompileTask('current', typesVersion);
+  yield makeCompileTask('current', '16.x');
 }
 
 BUILD_VARIANTS.push({
diff --git a/.evergreen/run-typescript.sh b/.evergreen/run-typescript.sh
index 8fa319bfccc..9bd212eb705 100644
--- a/.evergreen/run-typescript.sh
+++ b/.evergreen/run-typescript.sh
@@ -3,8 +3,6 @@ set -o errexit # Exit the script with error if any of the commands fail
 
 source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
 
-set -o xtrace
-
 case $TS_CHECK in
     COMPILE_DRIVER|CHECK_TYPES)  # Ok
         ;;
@@ -32,10 +30,11 @@ function get_ts_version() {
 export TSC="./node_modules/typescript/bin/tsc"
 export TS_VERSION=$(get_ts_version)
 
-# On old versions of TS we need to put the node types back to 18.11.19
-npm install --no-save --force typescript@"$TS_VERSION" "@types/node@$TYPES_VERSION"
+npm install --no-save --force "typescript@$TS_VERSION" "@types/node@$TYPES_VERSION"
 
 echo "Typescript $($TSC -v)"
+echo "Types: $(cat node_modules/@types/node/package.json | jq -r .version)"
+echo "Nodejs: $(node -v)"
 
 # check resolution uses the default latest types
 echo "import * as mdb from '.'" > file.ts && node $TSC --noEmit --traceResolution file.ts | grep 'mongodb.d.ts' && rm file.ts