From 2f72c3851650851d82a0873f0513173b51409e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Fri, 1 Feb 2019 19:56:16 +0900 Subject: [PATCH] Create type definition for 'deepcopy' (#4000) --- src/@types/deepcopy.d.ts | 17 +++++++++++++++++ src/models/abuse-user-report.ts | 2 +- src/models/app.ts | 2 +- src/models/auth-session.ts | 2 +- src/models/blocking.ts | 2 +- src/models/drive-file.ts | 2 +- src/models/drive-folder.ts | 2 +- src/models/favorite.ts | 2 +- src/models/follow-request.ts | 2 +- src/models/games/reversi/game.ts | 2 +- src/models/games/reversi/matching.ts | 2 +- src/models/messaging-message.ts | 2 +- src/models/mute.ts | 2 +- src/models/note-reaction.ts | 2 +- src/models/note.ts | 2 +- src/models/notification.ts | 2 +- src/models/signin.ts | 2 +- src/models/user-list.ts | 2 +- src/models/user.ts | 2 +- 19 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 src/@types/deepcopy.d.ts diff --git a/src/@types/deepcopy.d.ts b/src/@types/deepcopy.d.ts new file mode 100644 index 000000000..afeee5191 --- /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 1fe33f034..f3900d348 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 cf08ba1bd..14642e731 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 3458d5675..428c70747 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 4faf1a4d9..4bdaa741e 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 24c7ac75c..b34ba7ded 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 c95fdeb05..b0f6e4273 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 20176927a..0a8fec020 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 50235b8a9..4f75c63a3 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 3393932af..e0d1ad1be 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 981665ca2..ba2ac1bc0 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 2c7cf37cd..67abb4d11 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 13cd0c629..52775e13c 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 256ed8203..1152161ea 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 a872eb769..3548d1b8e 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 5cf1e140c..d49494391 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 55485d866..d8b05c0e3 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 ae231aff6..e7dd74bdd 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 ef091848f..66f515dda 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';