Skip to content

Commit

Permalink
Gtfo TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
sebamarynissen committed Jan 31, 2024
1 parent b977212 commit a441cb9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ module.exports = {
project: './tsconfig.eslint.json'
},
overrides: [
{
files: ['*ts'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
},
},
{
files: ['*.test.ts'],
env: {
Expand Down
23 changes: 11 additions & 12 deletions src/JobDbRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
MongoClientOptions,
ObjectId,
Sort,
UpdateFilter,
ModifyResult
UpdateFilter
} from 'mongodb';

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 4)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 5)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 4)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 6)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 6)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 4)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 4)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 5)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 4)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 5)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 5)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 6)

Cannot find module 'mongodb' or its corresponding type declarations.

Check failure on line 11 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 6)

Cannot find module 'mongodb' or its corresponding type declarations.
import type { Job, JobWithId } from './Job';
import type { Agenda } from './index';
Expand Down Expand Up @@ -109,15 +108,15 @@ export class JobDbRepository {

// Lock the job in MongoDB!
// @ts-ignore
const resp = await this.collection.findOneAndUpdate(
const resp = (await this.collection.findOneAndUpdate(
criteria as Filter<IJobParameters>,
update,
{
returnDocument: 'after',
sort: this.connectOptions.sort,
includeResultMetadata: true
}
) as any;
)) as any;

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 4)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 5)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 4)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 6)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 6)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 4)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 4)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 5)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 4)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 5)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 5)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 6, 4)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 6, 6)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 6)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 5)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 6)

Unexpected any. Specify a different type

Check warning on line 119 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 6)

Unexpected any. Specify a different type

return resp?.value || undefined;
}
Expand Down Expand Up @@ -153,15 +152,15 @@ export class JobDbRepository {

// Find ONE and ONLY ONE job and set the 'lockedAt' time so that job begins to be processed
// @ts-ignore
const result = await this.collection.findOneAndUpdate(
const result = (await this.collection.findOneAndUpdate(
JOB_PROCESS_WHERE_QUERY,
JOB_PROCESS_SET_QUERY,
{
returnDocument: 'after',
sort: this.connectOptions.sort,
includeResultMetadata: true
}
) as any;
)) as any;

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 4)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 5)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 4)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 6)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 6)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 4)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 4)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 5)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 4)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 7, 5)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 6, 5)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 6, 4)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 6, 6)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (18, 7, 6)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 5)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (20, 6, 6)

Unexpected any. Specify a different type

Check warning on line 163 in src/JobDbRepository.ts

View workflow job for this annotation

GitHub Actions / test (21, 7, 6)

Unexpected any. Specify a different type

return result.value || undefined;
}
Expand Down Expand Up @@ -309,14 +308,14 @@ export class JobDbRepository {
// Update the job and process the resulting data'
log('job already has _id, calling findOneAndUpdate() using _id as query');
// @ts-ignore
const result = await this.collection.findOneAndUpdate(
const result = (await this.collection.findOneAndUpdate(
{ _id: id, name: props.name },
update,
{
returnDocument: 'after',
includeResultMetadata: true
}
) as any;
)) as any;
return this.processDbResult(job, result.value as IJobParameters<DATA>);
}

Expand Down Expand Up @@ -347,7 +346,7 @@ export class JobDbRepository {
);
// this call ensure a job of this name can only exists once
// @ts-ignore
const result = await this.collection.findOneAndUpdate(
const result = (await this.collection.findOneAndUpdate(
{
name: props.name,
type: 'single'
Expand All @@ -358,7 +357,7 @@ export class JobDbRepository {
returnDocument: 'after',
includeResultMetadata: true
}
) as any;
)) as any;
log(
`findOneAndUpdate(${props.name}) with type "single" ${
result.lastErrorObject?.updatedExisting
Expand All @@ -380,11 +379,11 @@ export class JobDbRepository {
// Use the 'unique' query object to find an existing job or create a new one
log('calling findOneAndUpdate() with unique object as query: \n%O', query);
// @ts-ignore
const result = await this.collection.findOneAndUpdate(query as IJobParameters, update, {
const result = (await this.collection.findOneAndUpdate(query as IJobParameters, update, {
upsert: true,
returnDocument: 'after',
includeResultMetadata: true
}) as any;
})) as any;
return this.processDbResult(job, result.value as IJobParameters<DATA>);
}

Expand Down

0 comments on commit a441cb9

Please sign in to comment.