Skip to content

Commit

Permalink
fix(types): augument global jest
Browse files Browse the repository at this point in the history
  • Loading branch information
iamogbz committed Sep 24, 2020
1 parent 85de2a2 commit 24d47c9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
9 changes: 0 additions & 9 deletions src/globals.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getAllSpies = () => {
return spies;
};

export class MockProp<T> implements MockProp<T> {
export class MockProp<T> {
private initialPropDescriptor: PropertyDescriptor;
private initialPropValue: T;
private object: Obj<T>;
Expand Down
9 changes: 7 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export type Obj<T> = Record<string, T>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Spyable = Obj<any>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ValueOf<O> = O extends Record<infer _, infer T> ? T : any;

Expand All @@ -19,3 +17,10 @@ export type SpyOnProp = (
object: Spyable,
propName: string,
) => MockProp<ValueOf<typeof object>>;

declare global {
namespace jest {
const isMockProp: IsMockProp;
const spyOnProp: SpyOnProp;
}
}
2 changes: 1 addition & 1 deletion webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})),
Expand Down

0 comments on commit 24d47c9

Please sign in to comment.