Skip to content

chore(NODE-5324): update to typescript 5 #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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