Skip to content

Commit 27cf1d2

Browse files
authored
feat(NODE-3331): offer downleveled types for legacy typescript versions (#2859)
1 parent 05035eb commit 27cf1d2

File tree

7 files changed

+146
-93
lines changed

7 files changed

+146
-93
lines changed

.evergreen/run-checks.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
#!/bin/bash
2-
set -o errexit # Exit the script with error if any of the commands fail
2+
set -o errexit # Exit the script with error if any of the commands fail
33

44
export PROJECT_DIRECTORY="$(pwd)"
55
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
66
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
77
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
88

99
npm run check:lint
10+
11+
echo "Typescript $(npx tsc -v)"
12+
# check resolution uses the default latest types
13+
echo "import * as mdb from '.'" > file.ts && npx tsc --noEmit --traceResolution file.ts | grep 'mongodb.d.ts' && rm file.ts
14+
15+
npm i --no-save [email protected] # there is no 4.0.0
16+
echo "Typescript $(npx tsc -v)"
17+
npx tsc --noEmit mongodb.ts34.d.ts
18+
# check that resolution uses the downleveled types
19+
echo "import * as mdb from '.'" > file.ts && npx tsc --noEmit --traceResolution file.ts | grep 'mongodb.ts34.d.ts' && rm file.ts

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ For version compatibility matrices, please refer to the following links:
4141
- [MongoDB](https://docs.mongodb.com/drivers/node/compatibility#mongodb-compatibility)
4242
- [NodeJS](https://docs.mongodb.com/drivers/node/compatibility#language-compatibility)
4343

44+
#### Typescript Version
45+
46+
We recommend using the latest version of typescript, however we do provide a [downleveled](https://github.com/sandersn/downlevel-dts#readme) version of the type definitions that we test compiling against `[email protected]`.
47+
Since typescript [does not restrict breaking changes to major versions](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes) we consider this support best effort.
48+
If you run into any unexpected compiler failures please let us know and we will do our best to correct it.
49+
4450
## Installation
4551

4652
The recommended way to get started using the Node.js 4.0 driver is by using the `npm` (Node Package Manager) to install the dependency in your project.

0 commit comments

Comments
 (0)