Skip to content

Commit

Permalink
feat(world): disable definition of namespaces on external config for …
Browse files Browse the repository at this point in the history
…now (#2488)
  • Loading branch information
alvrs authored Mar 20, 2024
1 parent f24fac2 commit 9e34390
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/world/ts/config/v2/world.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it } from "vitest";
import { defineWorld } from "./world";
import { defineWorld, defineWorldWithoutNamespaces } from "./world";
import { attest } from "@arktype/attest";
import { resourceToHex } from "@latticexyz/common";
import {
Expand Down Expand Up @@ -715,3 +715,14 @@ describe("defineWorld", () => {
).throwsAndHasTypeError("Overrides of `name` and `namespace` are not allowed for tables in a store config");
});
});

describe("defineWorldWithoutNamespaces", () => {
it("should throw if namespaces are defined", () => {
attest(() =>
defineWorldWithoutNamespaces({
// @ts-expect-error Namespaces will be enabled soon
namespaces: {},
}),
).type.errors("Namespaces will be enabled soon");
});
});
8 changes: 8 additions & 0 deletions packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,11 @@ export function defineWorld<const world>(world: validateWorld<world>): resolveWo
validateWorld(world);
return resolveWorld(world) as unknown as resolveWorld<world>;
}

// Temporary external export of defineWorld with namespaces disabled
export function defineWorldWithoutNamespaces<const world>(
world: validateWorld<world> & { namespaces: `Namespaces will be enabled soon` },
): resolveWorld<world> {
validateWorld(world);
return resolveWorld(world) as unknown as resolveWorld<world>;
}
2 changes: 1 addition & 1 deletion packages/world/ts/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

export { helloWorldEvent, worldDeployedEvent } from "../worldEvents";

export { defineWorld } from "../config/v2/world";
export { defineWorldWithoutNamespaces as defineWorld } from "../config/v2/world";
export type { World } from "../config/v2/output";

0 comments on commit 9e34390

Please sign in to comment.