Skip to content

Commit

Permalink
chore(NODE-5324): update to typescript 5 (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
durran authored Jun 1, 2023
1 parent 259547d commit 81227bf
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 54 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": false,
"fixStyle": "inline-type-imports"
}
],
"no-bigint-usage/no-bigint-literals": "error",
"no-restricted-globals": [
"error",
Expand Down
67 changes: 27 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@microsoft/api-extractor": "^7.34.7",
"@microsoft/api-extractor": "^7.35.1",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-typescript": "^11.1.0",
"@types/chai": "^4.3.5",
Expand Down Expand Up @@ -56,7 +56,7 @@
"standard-version": "^9.5.0",
"ts-node": "^10.9.1",
"tsd": "^0.28.1",
"typescript": "^4.9.4",
"typescript": "^5.0.4",
"typescript-cached-transpile": "0.0.6",
"uuid": "^9.0.0",
"v8-profiler-next": "^1.9.0"
Expand Down
2 changes: 0 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const tsConfig = {
importHelpers: false,
noEmitHelpers: false,
noEmitOnError: true,
// make use of import type where applicable
importsNotUsedAsValues: 'error',
// Generate separate source maps files with sourceContent included
sourceMap: true,
inlineSourceMap: false,
Expand Down
4 changes: 2 additions & 2 deletions src/bson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { MinKey } from './min_key';
import { ObjectId } from './objectid';
import { internalCalculateObjectSize } from './parser/calculate_size';
// Parts of the parser
import { internalDeserialize, DeserializeOptions } from './parser/deserializer';
import { serializeInto, SerializeOptions } from './parser/serializer';
import { internalDeserialize, type DeserializeOptions } from './parser/deserializer';
import { serializeInto, type SerializeOptions } from './parser/serializer';
import { BSONRegExp } from './regexp';
import { BSONSymbol } from './symbol';
import { Timestamp } from './timestamp';
Expand Down
2 changes: 1 addition & 1 deletion src/parser/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Binary, UUID } from '../binary';
import type { Document } from '../bson';
import { Code } from '../code';
import * as constants from '../constants';
import { DBRef, DBRefLike, isDBRefLike } from '../db_ref';
import { DBRef, type DBRefLike, isDBRefLike } from '../db_ref';
import { Decimal128 } from '../decimal128';
import { Double } from '../double';
import { BSONError } from '../error';
Expand Down
12 changes: 7 additions & 5 deletions src/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,26 @@ export class Timestamp extends LongWithoutOverridesClass {
if (typeof low.i !== 'number' && (typeof low.i !== 'object' || low.i._bsontype !== 'Int32')) {
throw new BSONError('Timestamp constructed from { t, i } must provide i as a number');
}
if (low.t < 0) {
const t = Number(low.t);
const i = Number(low.i);
if (t < 0 || Number.isNaN(t)) {
throw new BSONError('Timestamp constructed from { t, i } must provide a positive t');
}
if (low.i < 0) {
if (i < 0 || Number.isNaN(i)) {
throw new BSONError('Timestamp constructed from { t, i } must provide a positive i');
}
if (low.t > 0xffff_ffff) {
if (t > 0xffff_ffff) {
throw new BSONError(
'Timestamp constructed from { t, i } must provide t equal or less than uint32 max'
);
}
if (low.i > 0xffff_ffff) {
if (i > 0xffff_ffff) {
throw new BSONError(
'Timestamp constructed from { t, i } must provide i equal or less than uint32 max'
);
}

super(low.i.valueOf(), low.t.valueOf(), true);
super(i, t, true);
} else {
throw new BSONError(
'A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }'
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"noEmitHelpers": false,
"noEmitOnError": true,
"emitDeclarationOnly": true,
// make use of import type where applicable
"importsNotUsedAsValues": "error",
// Generate separate source maps files with sourceContent included
"sourceMap": true,
"inlineSourceMap": false,
Expand Down

0 comments on commit 81227bf

Please sign in to comment.