@mittwald/react-ghostmaker 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,3 +40,10 @@ test("asGhost() works with generics", () => {
|
|
|
40
40
|
asGhost(prop).foo().use();
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
test("calling function on optional props works", () => {
|
|
44
|
+
const customerNameGhost = ProjectGhost.ofId("Project A")
|
|
45
|
+
.getDetailed()
|
|
46
|
+
.optionalCustomer?.getDetailed()
|
|
47
|
+
.getName();
|
|
48
|
+
expectTypeOf(customerNameGhost).toEqualTypeOf();
|
|
49
|
+
});
|
package/dist/esm/testMocks.js
CHANGED
|
@@ -37,6 +37,7 @@ export declare class ProjectDetailed {
|
|
|
37
37
|
readonly id: string;
|
|
38
38
|
readonly name: string;
|
|
39
39
|
readonly customer: Customer;
|
|
40
|
+
readonly optionalCustomer?: Customer;
|
|
40
41
|
constructor(id: string, name: string, customerId: string);
|
|
41
42
|
getName(): string;
|
|
42
43
|
getStatus(): Promise<string>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare const transformFnProp: "___transformFn";
|
|
|
22
22
|
export declare const isGhostMarker: "___ghostMarker";
|
|
23
23
|
type GhostProp<V, TOriginal> = V extends AnyFunction ? (...args: Parameters<V>) => ReactGhost<Awaited<ReturnType<V>> | OrOptional<TOriginal>> : ReactGhost<V | OrOptional<TOriginal>>;
|
|
24
24
|
export type ReactGhost<T> = ReactGhostMethods<T> & {
|
|
25
|
-
[K in keyof NonNullable<T>]-?: GhostProp<NonNullable<T>[K], T
|
|
25
|
+
[K in keyof NonNullable<T>]-?: Exclude<GhostProp<NonNullable<T>[K], T>, ReactGhost<undefined>>;
|
|
26
26
|
};
|
|
27
27
|
export interface GhostChainItem {
|
|
28
28
|
propName: string | typeof transformFnProp;
|