@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
+ });
@@ -186,6 +186,7 @@ let ProjectDetailed = (() => {
186
186
  id;
187
187
  name;
188
188
  customer;
189
+ optionalCustomer;
189
190
  constructor(id, name, customerId) {
190
191
  this.id = id;
191
192
  this.name = name;
@@ -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>;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/react-ghostmaker",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "author": "Mittwald CM Service GmbH & Co. KG <opensource@mittwald.de>",
5
5
  "contributors": [
6
6
  "Marco Falkenberg <m.falkenberg@mittwald.de>"