Skip to content

Commit

Permalink
feat(NODE-3331): offer downleveled types for legacy typescript versio…
Browse files Browse the repository at this point in the history
…ns (#2859)
  • Loading branch information
nbbeeken committed Jun 30, 2021
1 parent 05035eb commit 27cf1d2
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 93 deletions.
12 changes: 11 additions & 1 deletion .evergreen/run-checks.sh
@@ -1,9 +1,19 @@
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail
set -o errexit # Exit the script with error if any of the commands fail

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

npm run check:lint

echo "Typescript $(npx tsc -v)"
# check resolution uses the default latest types
echo "import * as mdb from '.'" > file.ts && npx tsc --noEmit --traceResolution file.ts | grep 'mongodb.d.ts' && rm file.ts

npm i --no-save typescript@4.0.2 # there is no 4.0.0
echo "Typescript $(npx tsc -v)"
npx tsc --noEmit mongodb.ts34.d.ts
# check that resolution uses the downleveled types
echo "import * as mdb from '.'" > file.ts && npx tsc --noEmit --traceResolution file.ts | grep 'mongodb.ts34.d.ts' && rm file.ts
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -41,6 +41,12 @@ For version compatibility matrices, please refer to the following links:
- [MongoDB](https://docs.mongodb.com/drivers/node/compatibility#mongodb-compatibility)
- [NodeJS](https://docs.mongodb.com/drivers/node/compatibility#language-compatibility)

#### Typescript Version

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 `typescript@4.0.2`.
Since typescript [does not restrict breaking changes to major versions](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes) we consider this support best effort.
If you run into any unexpected compiler failures please let us know and we will do our best to correct it.

## Installation

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.
Expand Down

0 comments on commit 27cf1d2

Please sign in to comment.