Skip to content

Commit 80b8032

Browse files
author
Dummy
committed
elaborated strict mode.
1 parent 1842020 commit 80b8032

23 files changed

+57
-34
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ console.log(fakeCalculator.divide(9, 5)); //prints 1338
146146
- Doesn't rely on object instances - you can produce a strong-typed fake from nothing, ensuring that everything is mocked.
147147

148148
# Beware
149+
## Names that conflict with Substitute.js
149150
Let's say we have a class with a method called `received`, `didNotReceive` or `mimick` keyword - how do we mock it?
150151

151152
Simple! We disable the proxy methods temporarily while invoking the method by using the `disableFor` method which disables these special methods.
@@ -167,4 +168,18 @@ Substitute.disableFor(fake).received(1337);
167168

168169
//now we can assert that we received a call to the "received" method.
169170
fake.received().received(1337);
171+
```
172+
173+
## Strict mode
174+
If you have `strict` set to `true` in your `tsconfig.json`, you may need to toggle off strict null checks. The framework does not currently support this.
175+
176+
However, it is only needed for your test projects anyway.
177+
178+
```json
179+
{
180+
"compilerOptions": {
181+
"strict": true,
182+
"strictNullChecks": false
183+
}
184+
}
170185
```

dist/spec/index.test.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export declare class Example {
44
a: string;
55
c(arg1: string, arg2: string): string;
66
readonly d: number;
7-
v: string;
7+
v: string | null | undefined;
88
received(stuff: number | string): void;
99
returnPromise(): Promise<Dummy>;
10-
foo(): string;
10+
foo(): string | undefined | null;
1111
}
1212
export {};

dist/spec/index.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Arguments.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export declare class AllArguments extends Argument<any> {
1212
}
1313
export declare class Arg {
1414
static all(): AllArguments;
15-
static any(): any;
15+
static any(): Argument<any> & any;
1616
static any<T extends 'string'>(type: T): Argument<string> & string;
1717
static any<T extends 'number'>(type: T): Argument<number> & number;
1818
static any<T extends 'boolean'>(type: T): Argument<boolean> & boolean;
1919
static any<T extends 'array'>(type: T): Argument<any[]> & any[];
2020
static any<T extends 'function'>(type: T): Argument<Function> & Function;
21-
static any<T extends 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array'>(type: T): any;
22-
static is<T>(predicate: (input: T) => boolean): Argument<T> & T;
21+
static any<T extends 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array'>(type: T): Argument<any> & any;
22+
static is<T>(predicate: (input: any) => boolean): Argument<T> & T;
2323
private static toStringify;
2424
}

dist/src/Arguments.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Transformations.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AllArguments } from "./Arguments";
22
export declare type NoArgumentFunctionSubstitute<TReturnType> = (() => (TReturnType & NoArgumentMockObjectMixin<TReturnType>));
33
export declare type FunctionSubstitute<TArguments extends any[], TReturnType> = ((...args: TArguments) => (TReturnType & MockObjectMixin<TArguments, TReturnType>)) & ((allArguments: AllArguments) => (TReturnType & MockObjectMixin<TArguments, TReturnType>));
4-
export declare type PropertySubstitute<TReturnType> = TReturnType & Partial<NoArgumentMockObjectMixin<TReturnType>>;
4+
export declare type PropertySubstitute<TReturnType> = (TReturnType & Partial<NoArgumentMockObjectMixin<TReturnType>>);
55
declare type BaseMockObjectMixin<TReturnType> = {
66
returns: (...args: TReturnType[]) => void;
77
};

dist/src/Transformations.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/states/FunctionState.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)