Skip to content

Commit f113a2b

Browse files
POC
1 parent 4b219d3 commit f113a2b

17 files changed

+177
-362
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@
271271
{
272272
// Settings for generated definition files
273273
"files": [
274-
"mongodb.d.ts"
274+
"**/*.d.ts",
275+
"lib/*.d.ts"
275276
],
276277
"parser": "@typescript-eslint/parser",
277278
"rules": {

.evergreen/config.in.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ functions:
348348
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
349349
TS_VERSION: ${TS_VERSION}
350350
TS_CHECK: CHECK_TYPES
351+
TYPES_VERSION: ${TYPES_VERSION}
351352
binary: bash
352353
args:
353354
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
@@ -362,6 +363,7 @@ functions:
362363
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
363364
TS_VERSION: ${TS_VERSION}
364365
TS_CHECK: COMPILE_DRIVER
366+
TYPES_VERSION: ${TYPES_VERSION}
365367
binary: bash
366368
args:
367369
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"

.evergreen/config.yml

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ functions:
312312
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
313313
TS_VERSION: ${TS_VERSION}
314314
TS_CHECK: CHECK_TYPES
315+
TYPES_VERSION: ${TYPES_VERSION}
315316
binary: bash
316317
args:
317318
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
@@ -325,6 +326,7 @@ functions:
325326
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
326327
TS_VERSION: ${TS_VERSION}
327328
TS_CHECK: COMPILE_DRIVER
329+
TYPES_VERSION: ${TYPES_VERSION}
328330
binary: bash
329331
args:
330332
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
@@ -3459,7 +3461,7 @@ tasks:
34593461
- {key: NPM_VERSION, value: '9'}
34603462
- func: install dependencies
34613463
- func: run lint checks
3462-
- name: check-types-typescript-next
3464+
- name: check-types-typescript-next-node-types-20.14.10
34633465
tags:
34643466
- check-types-typescript-next
34653467
- typescript-compilation
@@ -3471,11 +3473,12 @@ tasks:
34713473
- {key: NODE_LTS_VERSION, value: '16'}
34723474
- {key: NPM_VERSION, value: '9'}
34733475
- {key: TS_VERSION, value: next}
3476+
- {key: TYPES_VERSION, value: 20.14.10}
34743477
- func: install dependencies
34753478
- func: check types
3476-
- name: compile-driver-typescript-current
3479+
- name: check-types-typescript-current-node-types-20.14.10
34773480
tags:
3478-
- compile-driver-typescript-current
3481+
- check-types-typescript-current
34793482
- typescript-compilation
34803483
commands:
34813484
- command: expansions.update
@@ -3485,9 +3488,25 @@ tasks:
34853488
- {key: NODE_LTS_VERSION, value: '16'}
34863489
- {key: NPM_VERSION, value: '9'}
34873490
- {key: TS_VERSION, value: current}
3491+
- {key: TYPES_VERSION, value: 20.14.10}
34883492
- func: install dependencies
3489-
- func: compile driver
3490-
- name: check-types-typescript-current
3493+
- func: check types
3494+
- name: check-types-typescript-next-node-types-16.x
3495+
tags:
3496+
- check-types-typescript-next
3497+
- typescript-compilation
3498+
commands:
3499+
- command: expansions.update
3500+
type: setup
3501+
params:
3502+
updates:
3503+
- {key: NODE_LTS_VERSION, value: '16'}
3504+
- {key: NPM_VERSION, value: '9'}
3505+
- {key: TS_VERSION, value: next}
3506+
- {key: TYPES_VERSION, value: 16.x}
3507+
- func: install dependencies
3508+
- func: check types
3509+
- name: check-types-typescript-current-node-types-16.x
34913510
tags:
34923511
- check-types-typescript-current
34933512
- typescript-compilation
@@ -3499,9 +3518,10 @@ tasks:
34993518
- {key: NODE_LTS_VERSION, value: '16'}
35003519
- {key: NPM_VERSION, value: '9'}
35013520
- {key: TS_VERSION, value: current}
3521+
- {key: TYPES_VERSION, value: 16.x}
35023522
- func: install dependencies
35033523
- func: check types
3504-
- name: check-types-typescript-4.4
3524+
- name: check-types-typescript-4.4-node-types-18.11.9
35053525
tags:
35063526
- check-types-typescript-4.4
35073527
- typescript-compilation
@@ -3513,8 +3533,39 @@ tasks:
35133533
- {key: NODE_LTS_VERSION, value: '16'}
35143534
- {key: NPM_VERSION, value: '9'}
35153535
- {key: TS_VERSION, value: '4.4'}
3536+
- {key: TYPES_VERSION, value: 18.11.9}
35163537
- func: install dependencies
35173538
- func: check types
3539+
- name: compile-driver-typescript-current-node-types-20.14.10
3540+
tags:
3541+
- compile-driver-typescript-current
3542+
- typescript-compilation
3543+
commands:
3544+
- command: expansions.update
3545+
type: setup
3546+
params:
3547+
updates:
3548+
- {key: NODE_LTS_VERSION, value: '16'}
3549+
- {key: NPM_VERSION, value: '9'}
3550+
- {key: TS_VERSION, value: current}
3551+
- {key: TYPES_VERSION, value: 20.14.10}
3552+
- func: install dependencies
3553+
- func: compile driver
3554+
- name: compile-driver-typescript-current-node-types-16.x
3555+
tags:
3556+
- compile-driver-typescript-current
3557+
- typescript-compilation
3558+
commands:
3559+
- command: expansions.update
3560+
type: setup
3561+
params:
3562+
updates:
3563+
- {key: NODE_LTS_VERSION, value: '16'}
3564+
- {key: NPM_VERSION, value: '9'}
3565+
- {key: TS_VERSION, value: current}
3566+
- {key: TYPES_VERSION, value: 16.x}
3567+
- func: install dependencies
3568+
- func: compile driver
35183569
- name: download-and-merge-coverage
35193570
tags: []
35203571
commands:

.evergreen/generate_evergreen_tasks.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -497,51 +497,51 @@ SINGLETON_TASKS.push(
497497
);
498498

499499
function* makeTypescriptTasks() {
500-
for (const TS_VERSION of ['next', 'current', '4.4']) {
501-
// We don't compile on next, because compilation errors are likely. We do expect
502-
// that the drivers types continue to work with next though.
503-
if (TS_VERSION !== '4.4' && TS_VERSION !== 'next') {
504-
yield {
505-
name: `compile-driver-typescript-${TS_VERSION}`,
506-
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
507-
commands: [
508-
updateExpansions({
509-
NODE_LTS_VERSION: LOWEST_LTS,
510-
NPM_VERSION: 9,
511-
TS_VERSION
512-
}),
513-
{ func: 'install dependencies' },
514-
{ func: 'compile driver' }
515-
]
516-
};
500+
function makeCompileTask(TS_VERSION, TYPES_VERSION) {
501+
return {
502+
name: `compile-driver-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
503+
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
504+
commands: [
505+
updateExpansions({
506+
NODE_LTS_VERSION: LOWEST_LTS,
507+
NPM_VERSION: 9,
508+
TS_VERSION,
509+
TYPES_VERSION
510+
}),
511+
{ func: 'install dependencies' },
512+
{ func: 'compile driver' }
513+
]
517514
}
518-
519-
yield {
520-
name: `check-types-typescript-${TS_VERSION}`,
515+
}
516+
function makeCheckTypesTask(TS_VERSION, TYPES_VERSION) {
517+
return {
518+
name: `check-types-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
521519
tags: [`check-types-typescript-${TS_VERSION}`, 'typescript-compilation'],
522520
commands: [
523521
updateExpansions({
524522
NODE_LTS_VERSION: LOWEST_LTS,
525523
NPM_VERSION: 9,
526-
TS_VERSION
524+
TS_VERSION,
525+
TYPES_VERSION
527526
}),
528527
{ func: 'install dependencies' },
529528
{ func: 'check types' }
530529
]
531-
};
530+
}
532531
}
533-
return {
534-
name: 'run-typescript-next',
535-
tags: ['run-typescript-next', 'typescript-compilation'],
536-
commands: [
537-
updateExpansions({
538-
NODE_LTS_VERSION: LOWEST_LTS,
539-
NPM_VERSION: 9
540-
}),
541-
{ func: 'install dependencies' },
542-
{ func: 'run typescript next' }
543-
]
544-
};
532+
533+
const typesVersion = require('../package.json').devDependencies['@types/node'].slice(1)
534+
yield makeCheckTypesTask('next', typesVersion);
535+
yield makeCheckTypesTask('current', typesVersion);
536+
537+
yield makeCheckTypesTask('next', '16.x');
538+
yield makeCheckTypesTask('current', '16.x');
539+
540+
// typescript 4.4 only compiles our types with this particular version
541+
yield makeCheckTypesTask('4.4', '18.11.9');
542+
543+
yield makeCompileTask('current', typesVersion);
544+
yield makeCompileTask('current', '16.x');
545545
}
546546

547547
BUILD_VARIANTS.push({

.evergreen/run-typescript.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ set -o errexit # Exit the script with error if any of the commands fail
33

44
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
55

6-
set -o xtrace
7-
86
case $TS_CHECK in
97
COMPILE_DRIVER|CHECK_TYPES) # Ok
108
;;
@@ -14,6 +12,7 @@ case $TS_CHECK in
1412
esac
1513

1614
if [ -z "$TS_VERSION" ]; then echo "TS_VERSION must be set"; exit 1; fi
15+
if [ -z "$TYPES_VERSION" ]; then echo "TYPES_VERSION must be set"; exit 1; fi
1716

1817
if [ ! -f "mongodb.d.ts" ]; then
1918
echo "mongodb.d.ts should always exist because of the installation in prior steps but in case it doesn't, build it"
@@ -31,10 +30,11 @@ function get_ts_version() {
3130
export TSC="./node_modules/typescript/bin/tsc"
3231
export TS_VERSION=$(get_ts_version)
3332

34-
# On old versions of TS we need to put the node types back to 18.11.19
35-
npm install --no-save --force typescript@"$TS_VERSION" "$(if [[ $TS_VERSION == '4.4' ]]; then echo "@types/[email protected]"; else echo ""; fi)"
33+
npm install --no-save --force "typescript@$TS_VERSION" "@types/node@$TYPES_VERSION"
3634

3735
echo "Typescript $($TSC -v)"
36+
echo "Types: $(cat node_modules/@types/node/package.json | jq -r .version)"
37+
echo "Nodejs: $(node -v)"
3838

3939
# check resolution uses the default latest types
4040
echo "import * as mdb from '.'" > file.ts && node $TSC --noEmit --traceResolution file.ts | grep 'mongodb.d.ts' && rm file.ts

api-extractor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"dtsRollup": {
1111
"enabled": true,
1212
"untrimmedFilePath": "",
13-
"publicTrimmedFilePath": "<projectFolder>/<unscopedPackageName>.d.ts"
13+
"publicTrimmedFilePath": "<projectFolder>/<unscopedPackageName>.d.ts",
14+
"betaTrimmedFilePath": "<projectFolder>/lib/beta.d.ts"
1415
},
1516
"tsdocMetadata": {
1617
"enabled": false

etc/clean_definition_files.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (fs.existsSync(libPath)) {
2121
const definitionFiles = Array.from(walk(libPath)).filter(filePath => {
2222
return filePath.endsWith('.d.ts') || filePath.endsWith('.d.ts.map');
2323
});
24-
for (const definitionFile of definitionFiles) {
24+
for (const definitionFile of definitionFiles.filter(file => !file.endsWith('beta.d.ts'))) {
2525
fs.unlinkSync(definitionFile);
2626
}
2727
}

0 commit comments

Comments
 (0)