From 24d47c9796422f68cb28bd1c0bac497f1072416a Mon Sep 17 00:00:00 2001 From: Emmanuel Ogbizi-Ugbe Date: Thu, 24 Sep 2020 08:25:28 -0400 Subject: [PATCH] fix(types): augument global jest --- src/globals.d.ts | 9 --------- src/index.ts | 2 +- src/types.d.ts | 9 +++++++-- webpack.config.ts | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) delete mode 100644 src/globals.d.ts diff --git a/src/globals.d.ts b/src/globals.d.ts deleted file mode 100644 index fee33e14..00000000 --- a/src/globals.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { IsMockProp, SpyOnProp } from "./types"; - -declare global { - namespace jest { - const isMockProp: IsMockProp; - const spyOnProp: SpyOnProp; - } -} diff --git a/src/index.ts b/src/index.ts index 62e2bea6..863379e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,7 +35,7 @@ const getAllSpies = () => { return spies; }; -export class MockProp implements MockProp { +export class MockProp { private initialPropDescriptor: PropertyDescriptor; private initialPropValue: T; private object: Obj; diff --git a/src/types.d.ts b/src/types.d.ts index 80bf6960..2d1f6bf9 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,8 +1,6 @@ export type Obj = Record; - // eslint-disable-next-line @typescript-eslint/no-explicit-any export type Spyable = Obj; - // eslint-disable-next-line @typescript-eslint/no-explicit-any export type ValueOf = O extends Record ? T : any; @@ -19,3 +17,10 @@ export type SpyOnProp = ( object: Spyable, propName: string, ) => MockProp>; + +declare global { + namespace jest { + const isMockProp: IsMockProp; + const spyOnProp: SpyOnProp; + } +} diff --git a/webpack.config.ts b/webpack.config.ts index d4cf5be9..c1c87732 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -43,7 +43,7 @@ const configuration: Configuration = { stageMessages: null, }), new CopyWebpackPlugin({ - patterns: ["types", "globals"].map((t) => ({ + patterns: ["types"].map((t) => ({ from: `./src/${t}.d.ts`, to: outputPath, })),