import { MainEffects, StartSdk } from "../StartSdk" import { Effects } from "../types" type Store = { config: { someValue: "a" | "b" } } type Manifest = any const todo = (): A => { throw new Error("not implemented") } const noop = () => {} const sdk = StartSdk.of() .withManifest({} as Manifest) .withStore() .build(true) describe("Store", () => { test("types", async () => { ;async () => { sdk.store.setOwn(todo(), "/config", { someValue: "a", }) sdk.store.setOwn(todo(), "/config/someValue", "b") sdk.store.setOwn(todo(), "", { config: { someValue: "b" }, }) sdk.store.setOwn( todo(), "/config/someValue", // @ts-expect-error Type is wrong for the setting value 5, ) sdk.store.setOwn( todo(), // @ts-expect-error Path is wrong "/config/someVae3lue", "someValue", ) todo().store.set({ path: "/config/someValue", value: "b", }) todo().store.set({ //@ts-expect-error Path is wrong path: "/config/someValue", //@ts-expect-error Path is wrong value: "someValueIn", }) todo().store.set({ //@ts-expect-error Path is wrong path: "/config/some2Value", value: "a", }) ;(await sdk.store .getOwn(todo(), "/config/someValue") .const()) satisfies string ;(await sdk.store .getOwn(todo(), "/config") .const()) satisfies Store["config"] await sdk.store // @ts-expect-error Path is wrong .getOwn(todo(), "/config/somdsfeValue") .const() /// ----------------- ERRORS ----------------- sdk.store.setOwn(todo(), "", { // @ts-expect-error Type is wrong for the setting value config: { someValue: "notInAOrB" }, }) sdk.store.setOwn( todo(), "/config/someValue", // @ts-expect-error Type is wrong for the setting value "notInAOrB", ) ;(await sdk.store .getOwn(todo(), "/config/someValue") // @ts-expect-error Const should normally not be callable .const()) satisfies string ;(await sdk.store .getOwn(todo(), "/config") // @ts-expect-error Const should normally not be callable .const()) satisfies Store["config"] await sdk.store // @ts-expect-error Path is wrong .getOwn("/config/somdsfeValue") // @ts-expect-error Const should normally not be callable .const() /// ;(await sdk.store .getOwn(todo(), "/config/someValue") // @ts-expect-error satisfies type is wrong .const()) satisfies number ;(await sdk.store // @ts-expect-error Path is wrong .getOwn(todo(), "/config/") .const()) satisfies Store["config"] ;(await todo().store.get({ path: "/config/someValue", callback: noop, })) satisfies string await todo().store.get({ // @ts-expect-error Path is wrong as in it doesn't match above path: "/config/someV2alue", callback: noop, }) await todo().store.get({ // @ts-expect-error Path is wrong as in it doesn't exists in wrapper type path: "/config/someV2alue", callback: noop, }) } }) })