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 authored and ljhaywar committed Nov 9, 2021
1 parent 4be0e75 commit eb3f0a3
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
Original file line number Diff line number Diff line change
@@ -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 [email protected] # 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
Original file line number Diff line number Diff line change
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 `[email protected]`.
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
Loading

0 comments on commit eb3f0a3

Please sign in to comment.