Skip to content

Commit 81227bf

Browse files
authored
chore(NODE-5324): update to typescript 5 (#579)
1 parent 259547d commit 81227bf

File tree

8 files changed

+47
-54
lines changed

8 files changed

+47
-54
lines changed

.eslintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464
"@typescript-eslint/no-unsafe-return": "off",
6565
"@typescript-eslint/no-unsafe-argument": "off",
6666
"@typescript-eslint/no-unsafe-call": "off",
67+
"@typescript-eslint/consistent-type-imports": [
68+
"error",
69+
{
70+
"prefer": "type-imports",
71+
"disallowTypeAnnotations": false,
72+
"fixStyle": "inline-type-imports"
73+
}
74+
],
6775
"no-bigint-usage/no-bigint-literals": "error",
6876
"no-restricted-globals": [
6977
"error",

package-lock.json

Lines changed: 27 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@istanbuljs/nyc-config-typescript": "^1.0.2",
29-
"@microsoft/api-extractor": "^7.34.7",
29+
"@microsoft/api-extractor": "^7.35.1",
3030
"@rollup/plugin-node-resolve": "^15.0.2",
3131
"@rollup/plugin-typescript": "^11.1.0",
3232
"@types/chai": "^4.3.5",
@@ -56,7 +56,7 @@
5656
"standard-version": "^9.5.0",
5757
"ts-node": "^10.9.1",
5858
"tsd": "^0.28.1",
59-
"typescript": "^4.9.4",
59+
"typescript": "^5.0.4",
6060
"typescript-cached-transpile": "0.0.6",
6161
"uuid": "^9.0.0",
6262
"v8-profiler-next": "^1.9.0"

rollup.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ const tsConfig = {
1616
importHelpers: false,
1717
noEmitHelpers: false,
1818
noEmitOnError: true,
19-
// make use of import type where applicable
20-
importsNotUsedAsValues: 'error',
2119
// Generate separate source maps files with sourceContent included
2220
sourceMap: true,
2321
inlineSourceMap: false,

src/bson.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { MinKey } from './min_key';
1010
import { ObjectId } from './objectid';
1111
import { internalCalculateObjectSize } from './parser/calculate_size';
1212
// Parts of the parser
13-
import { internalDeserialize, DeserializeOptions } from './parser/deserializer';
14-
import { serializeInto, SerializeOptions } from './parser/serializer';
13+
import { internalDeserialize, type DeserializeOptions } from './parser/deserializer';
14+
import { serializeInto, type SerializeOptions } from './parser/serializer';
1515
import { BSONRegExp } from './regexp';
1616
import { BSONSymbol } from './symbol';
1717
import { Timestamp } from './timestamp';

src/parser/deserializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Binary, UUID } from '../binary';
22
import type { Document } from '../bson';
33
import { Code } from '../code';
44
import * as constants from '../constants';
5-
import { DBRef, DBRefLike, isDBRefLike } from '../db_ref';
5+
import { DBRef, type DBRefLike, isDBRefLike } from '../db_ref';
66
import { Decimal128 } from '../decimal128';
77
import { Double } from '../double';
88
import { BSONError } from '../error';

src/timestamp.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,26 @@ export class Timestamp extends LongWithoutOverridesClass {
6161
if (typeof low.i !== 'number' && (typeof low.i !== 'object' || low.i._bsontype !== 'Int32')) {
6262
throw new BSONError('Timestamp constructed from { t, i } must provide i as a number');
6363
}
64-
if (low.t < 0) {
64+
const t = Number(low.t);
65+
const i = Number(low.i);
66+
if (t < 0 || Number.isNaN(t)) {
6567
throw new BSONError('Timestamp constructed from { t, i } must provide a positive t');
6668
}
67-
if (low.i < 0) {
69+
if (i < 0 || Number.isNaN(i)) {
6870
throw new BSONError('Timestamp constructed from { t, i } must provide a positive i');
6971
}
70-
if (low.t > 0xffff_ffff) {
72+
if (t > 0xffff_ffff) {
7173
throw new BSONError(
7274
'Timestamp constructed from { t, i } must provide t equal or less than uint32 max'
7375
);
7476
}
75-
if (low.i > 0xffff_ffff) {
77+
if (i > 0xffff_ffff) {
7678
throw new BSONError(
7779
'Timestamp constructed from { t, i } must provide i equal or less than uint32 max'
7880
);
7981
}
8082

81-
super(low.i.valueOf(), low.t.valueOf(), true);
83+
super(i, t, true);
8284
} else {
8385
throw new BSONError(
8486
'A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }'

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
"noEmitHelpers": false,
1717
"noEmitOnError": true,
1818
"emitDeclarationOnly": true,
19-
// make use of import type where applicable
20-
"importsNotUsedAsValues": "error",
2119
// Generate separate source maps files with sourceContent included
2220
"sourceMap": true,
2321
"inlineSourceMap": false,

0 commit comments

Comments
 (0)