diff --git a/src/@types/deepcopy.d.ts b/src/@types/deepcopy.d.ts new file mode 100644 index 0000000000..afeee51913 --- /dev/null +++ b/src/@types/deepcopy.d.ts @@ -0,0 +1,17 @@ +declare module 'deepcopy'; + +declare namespace deepcopy { + type DeepcopyCustomizerValueType = 'Object'; + + type DeepcopyCustomizer = ( + value: T, + valueType: DeepcopyCustomizerValueType) => T; + + interface DeepcopyOptions { + customizer: DeepcopyCustomizer + } + + export function deepcopy( + value: T, + options?: DeepcopyOptions | DeepcopyCustomizer): T; +} diff --git a/src/models/abuse-user-report.ts b/src/models/abuse-user-report.ts index 1fe33f0342..f3900d348d 100644 --- a/src/models/abuse-user-report.ts +++ b/src/models/abuse-user-report.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import { pack as packUser } from './user'; diff --git a/src/models/app.ts b/src/models/app.ts index cf08ba1bda..14642e7314 100644 --- a/src/models/app.ts +++ b/src/models/app.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import AccessToken from './access-token'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; diff --git a/src/models/auth-session.ts b/src/models/auth-session.ts index 3458d5675f..428c707470 100644 --- a/src/models/auth-session.ts +++ b/src/models/auth-session.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import { pack as packApp } from './app'; diff --git a/src/models/blocking.ts b/src/models/blocking.ts index 4faf1a4d93..4bdaa741e9 100644 --- a/src/models/blocking.ts +++ b/src/models/blocking.ts @@ -1,7 +1,7 @@ import * as mongo from 'mongodb'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import { pack as packUser, IUser } from './user'; const Blocking = db.get('blocking'); diff --git a/src/models/drive-file.ts b/src/models/drive-file.ts index 24c7ac75c0..b34ba7ded8 100644 --- a/src/models/drive-file.ts +++ b/src/models/drive-file.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import { pack as packFolder } from './drive-folder'; import { pack as packUser } from './user'; import monkDb, { nativeDbConn } from '../db/mongodb'; diff --git a/src/models/drive-folder.ts b/src/models/drive-folder.ts index c95fdeb05d..b0f6e4273e 100644 --- a/src/models/drive-folder.ts +++ b/src/models/drive-folder.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import DriveFile from './drive-file'; diff --git a/src/models/favorite.ts b/src/models/favorite.ts index 20176927ae..0a8fec020f 100644 --- a/src/models/favorite.ts +++ b/src/models/favorite.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import { pack as packNote } from './note'; diff --git a/src/models/follow-request.ts b/src/models/follow-request.ts index 50235b8a9d..4f75c63a32 100644 --- a/src/models/follow-request.ts +++ b/src/models/follow-request.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import { pack as packUser } from './user'; diff --git a/src/models/games/reversi/game.ts b/src/models/games/reversi/game.ts index 3393932af8..e0d1ad1beb 100644 --- a/src/models/games/reversi/game.ts +++ b/src/models/games/reversi/game.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../../../db/mongodb'; import isObjectId from '../../../misc/is-objectid'; import { IUser, pack as packUser } from '../../user'; diff --git a/src/models/games/reversi/matching.ts b/src/models/games/reversi/matching.ts index 981665ca2c..ba2ac1bc05 100644 --- a/src/models/games/reversi/matching.ts +++ b/src/models/games/reversi/matching.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../../../db/mongodb'; import isObjectId from '../../../misc/is-objectid'; import { IUser, pack as packUser } from '../../user'; diff --git a/src/models/messaging-message.ts b/src/models/messaging-message.ts index 2c7cf37cd8..67abb4d111 100644 --- a/src/models/messaging-message.ts +++ b/src/models/messaging-message.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import { pack as packUser } from './user'; import { pack as packFile } from './drive-file'; import db from '../db/mongodb'; diff --git a/src/models/mute.ts b/src/models/mute.ts index 13cd0c6293..52775e13ca 100644 --- a/src/models/mute.ts +++ b/src/models/mute.ts @@ -1,7 +1,7 @@ import * as mongo from 'mongodb'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import { pack as packUser, IUser } from './user'; const Mute = db.get('mute'); diff --git a/src/models/note-reaction.ts b/src/models/note-reaction.ts index 256ed8203f..1152161ea5 100644 --- a/src/models/note-reaction.ts +++ b/src/models/note-reaction.ts @@ -1,6 +1,6 @@ import * as mongo from 'mongodb'; import $ from 'cafy'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import Reaction from './note-reaction'; diff --git a/src/models/note.ts b/src/models/note.ts index a872eb7696..3548d1b8ec 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import rap from '@prezzemolo/rap'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; diff --git a/src/models/notification.ts b/src/models/notification.ts index 5cf1e140c8..d49494391e 100644 --- a/src/models/notification.ts +++ b/src/models/notification.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; import { IUser, pack as packUser } from './user'; diff --git a/src/models/signin.ts b/src/models/signin.ts index 55485d8667..d8b05c0e30 100644 --- a/src/models/signin.ts +++ b/src/models/signin.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; const Signin = db.get('signin'); diff --git a/src/models/user-list.ts b/src/models/user-list.ts index ae231aff62..e7dd74bdd1 100644 --- a/src/models/user-list.ts +++ b/src/models/user-list.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid'; diff --git a/src/models/user.ts b/src/models/user.ts index ef091848f9..66f515ddab 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -const deepcopy = require('deepcopy'); +import * as deepcopy from 'deepcopy'; import rap from '@prezzemolo/rap'; import db from '../db/mongodb'; import isObjectId from '../misc/is-objectid';