Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IDeepNestedEnumerable {
id: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IDeepNestedEnumerable } from "./deep-nested-enumerable.entity";
import { Model } from "/types";

export const DeepNestedEnumerable: Model<IDeepNestedEnumerable> = {
id: true,
};
14 changes: 14 additions & 0 deletions test/types/store/.internals/enumerable/enumerable.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { INestedEnumerable } from "../nested-enumerable/nested-enumerable.entity";
import { ISingleton } from "../singleton/singleton.entity";

export interface IEnumerable {
id: string;
stringProperty: string;
numberProperty: number;
self: IEnumerable;
nestedSingleton: ISingleton;
optionalNestedSingleton?: ISingleton;
nestedEnumerable: INestedEnumerable;
optionalNestedEnumerable?: INestedEnumerable;
nestedEnumerables: INestedEnumerable[];
}
16 changes: 16 additions & 0 deletions test/types/store/.internals/enumerable/enumerable.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NestedEnumerable } from "../nested-enumerable/nested-enumerable.store";
import { Singleton } from "../singleton/singleton.store";
import { IEnumerable } from "./enumerable.entity";
import { ModelDefinition, store } from "/types";

export const Enumerable: ModelDefinition<IEnumerable> = {
id: true,
stringProperty: "",
numberProperty: 0,
self: store.ref(() => Enumerable),
nestedSingleton: store.ref(() => Singleton),
optionalNestedSingleton: store.ref(() => Singleton),
nestedEnumerable: store.ref(() => NestedEnumerable),
optionalNestedEnumerable: store.ref(() => NestedEnumerable),
nestedEnumerables: store.ref(() => [NestedEnumerable]),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { IDeepNestedEnumerable } from "../deep-nested-enumerable/deep-nested-enumerable.entity";
import { ISingleton } from "../singleton/singleton.entity";

export interface INestedEnumerable {
id: string;
stringProperty: string;
numberProperty: number;
nestedSingleton: ISingleton;
optionalNestedSingleton?: ISingleton;
nestedEnumerable: IDeepNestedEnumerable;
optionalNestedEnumerable?: IDeepNestedEnumerable;
nestedEnumerables: IDeepNestedEnumerable[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DeepNestedEnumerable } from "../deep-nested-enumerable/deep-nested-enumerable.store";
import { Singleton } from "../singleton/singleton.store";
import { INestedEnumerable } from "./nested-enumerable.entity";
import { Model, store } from "/types";

export const NestedEnumerable: Model<INestedEnumerable> = {
id: true,
stringProperty: "",
numberProperty: 0,
nestedSingleton: store.ref(() => Singleton),
optionalNestedSingleton: store.ref(() => Singleton),
nestedEnumerable: store.ref(() => DeepNestedEnumerable),
optionalNestedEnumerable: store.ref(() => DeepNestedEnumerable),
nestedEnumerables: store.ref(() => [DeepNestedEnumerable]),
};
12 changes: 12 additions & 0 deletions test/types/store/.internals/singleton/singleton.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { INestedEnumerable } from "../nested-enumerable/nested-enumerable.entity";

export interface ISingleton {
stringProperty: string;
numberProperty: number;
self: ISingleton;
nestedSingleton: ISingleton;
optionalNestedSingleton?: ISingleton;
nestedEnumerable: INestedEnumerable;
optionalNestedEnumerable?: INestedEnumerable;
nestedEnumerables: INestedEnumerable[];
}
27 changes: 27 additions & 0 deletions test/types/store/.internals/singleton/singleton.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { NestedEnumerable } from "../nested-enumerable/nested-enumerable.store";
import { ISingleton } from "./singleton.entity";
import { ModelDefinition, store } from "/types";

export const Singleton: ModelDefinition<ISingleton> = {
stringProperty: "",
numberProperty: 0,
self: store.ref(() => Singleton),
nestedSingleton: store.ref(() => Singleton),
optionalNestedSingleton: store.ref(() => Singleton),
nestedEnumerable: store.ref(() => NestedEnumerable),
optionalNestedEnumerable: store.ref(() => NestedEnumerable),
nestedEnumerables: store.ref(() => [NestedEnumerable]),
};

const BrokenSingleton: ModelDefinition<ISingleton> = {
/// @ts-expect-error
id: true,
stringProperty: "",
numberProperty: 0,
self: store.ref(() => Singleton),
nestedSingleton: store.ref(() => Singleton),
optionalNestedSingleton: store.ref(() => Singleton),
nestedEnumerable: store.ref(() => NestedEnumerable),
optionalNestedEnumerable: store.ref(() => NestedEnumerable),
nestedEnumerables: store.ref(() => [NestedEnumerable]),
};
122 changes: 0 additions & 122 deletions test/types/store/descriptor.ts

This file was deleted.

117 changes: 0 additions & 117 deletions test/types/store/direct-methods.ts

This file was deleted.

22 changes: 22 additions & 0 deletions test/types/store/direct-methods/clear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Enumerable } from "../.internals/enumerable/enumerable.store";
import { Singleton } from "../.internals/singleton/singleton.store";
import { store } from "/types";

const singleton = store.get(Singleton);
const enumerable = store.sync(Enumerable, { id: "1" });

// Overload via Definition
{
store.clear(Singleton);
store.clear(Enumerable);
store.clear(Singleton, true);
store.clear(Enumerable, true);
}

// Overload via instance
{
store.clear(singleton);
store.clear(enumerable);
store.clear(singleton, true);
store.clear(enumerable, true);
}
Loading