diff --git a/.eslintrc b/.eslintrc index f40adf9283..b67a090914 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,6 +14,7 @@ { "extendDefaults": true, "types": { + // don't throw an error for the empty object type ({}) "{}": false, }, }, diff --git a/packages/store/ts/config/v2/store.test.ts b/packages/store/ts/config/v2/store.test.ts index 68d0389c16..22c1cff2ea 100644 --- a/packages/store/ts/config/v2/store.test.ts +++ b/packages/store/ts/config/v2/store.test.ts @@ -37,6 +37,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -74,6 +75,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -119,6 +121,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -164,6 +167,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -247,6 +251,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -300,6 +305,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }), it("it should return the full config given a full config with two primaryKey", () => { @@ -351,6 +357,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -440,6 +447,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -530,6 +538,7 @@ describe("resolveStoreConfig", () => { enums: {}, namespace: "", } as const; + attest(config); }); @@ -637,11 +646,13 @@ describe("resolveStoreConfig", () => { }, namespace: "", } as const; + attest(config); }); it("should use the root namespace as default namespace", () => { const config = resolveStoreConfig({ tables: { Example: {} } }); + attest<"">(config.namespace); }); }); diff --git a/packages/store/ts/config/v2/store.ts b/packages/store/ts/config/v2/store.ts index 5f86742e57..598d3b58aa 100644 --- a/packages/store/ts/config/v2/store.ts +++ b/packages/store/ts/config/v2/store.ts @@ -50,7 +50,7 @@ export type validateStoreConfig = { : input[key]; }; -export type resolveEnums = { [key in keyof enums]: Readonly }; +export type resolveEnums = { readonly [key in keyof enums]: Readonly }; export type resolveStoreConfig = evaluate<{ readonly tables: "tables" extends keyof input ? resolveStoreTablesConfig> : {}; diff --git a/packages/store/ts/config/v2/table.test.ts b/packages/store/ts/config/v2/table.test.ts index 6a22382035..505dc8e45b 100644 --- a/packages/store/ts/config/v2/table.test.ts +++ b/packages/store/ts/config/v2/table.test.ts @@ -13,6 +13,7 @@ describe("validateKeys", () => { it("should return a tuple of valid keys with an extended scope", () => { const scope = extendScope(AbiTypeScope, { static: "address", dynamic: "string" }); + attest< ["static", "customStatic"], validateKeys< @@ -34,6 +35,7 @@ describe("validateKeys", () => { it("should return a tuple of valid keys with an extended scope", () => { const scope = extendScope(AbiTypeScope, { static: "address", dynamic: "string" }); + attest< ["static", "customStatic"], validateKeys< @@ -50,6 +52,7 @@ describe("validateKeys", () => { describe("resolveTableShorthand", () => { it("should expand a single ABI type into a key/value schema", () => { const table = resolveTableShorthand("address"); + attest<{ schema: { key: "bytes32"; @@ -62,6 +65,7 @@ describe("resolveTableShorthand", () => { it("should expand a single custom into a key/value schema", () => { const scope = extendScope(AbiTypeScope, { CustomType: "uint256" }); const table = resolveTableShorthand("CustomType", scope); + attest<{ schema: { key: "bytes32"; @@ -88,6 +92,7 @@ describe("resolveTableShorthand", () => { it("should use `key` as single key if it has a static ABI type", () => { const table = resolveTableShorthand({ key: "address", name: "string", age: "uint256" }); + attest<{ schema: { key: "address"; @@ -124,6 +129,7 @@ describe("resolveTableShorthand", () => { it("should use `key` as single key if it has a static custom type", () => { const scope = extendScope(AbiTypeScope, { CustomType: "uint256" }); const table = resolveTableShorthand({ key: "CustomType", name: "string", age: "uint256" }, scope); + attest<{ schema: { key: "CustomType"; name: "string"; age: "uint256" }; primaryKey: ["key"]; @@ -134,6 +140,7 @@ describe("resolveTableShorthand", () => { it("should throw an error if `key` is not a custom static type", () => { const scope = extendScope(AbiTypeScope, { CustomType: "bytes" }); + // @ts-expect-error "Error: Provide a `key` field with static ABI type or a full config with explicit primaryKey override." attest(resolveTableShorthand({ key: "CustomType", name: "string", age: "uint256" }, scope)).type.errors( `Provide a \`key\` field with static ABI type or a full config with explicit primaryKey override.`, @@ -169,6 +176,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["key"], } as const; + attest(table); }); @@ -200,6 +208,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["key"], } as const; + attest(table); }); @@ -238,6 +247,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["key"], } as const; + attest(table); }); @@ -277,6 +287,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["key"], } as const; + attest(table); }); @@ -329,6 +340,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["age"], } as const; + attest(table); }); @@ -352,6 +364,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["age", "key"], } as const; + attest(table); }); @@ -391,6 +404,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["key"], } as const; + attest(table); }); @@ -430,6 +444,7 @@ describe("resolveTableConfig", () => { }, primaryKey: ["key"], } as const; + attest(table); }); diff --git a/packages/world/ts/config/v2/world.test.ts b/packages/world/ts/config/v2/world.test.ts index c9b45557b1..5ea74d13c8 100644 --- a/packages/world/ts/config/v2/world.test.ts +++ b/packages/world/ts/config/v2/world.test.ts @@ -253,6 +253,7 @@ describe("resolveWorldConfig", () => { namespace: "", namespaces: {}, } as const; + attest(expected); }); @@ -470,6 +471,7 @@ describe("resolveWorldConfig", () => { namespace: "", namespaces: {}, } as const; + attest(config); }); @@ -669,6 +671,7 @@ describe("resolveWorldConfig", () => { namespace: "", namespaces: {}, } as const; + attest(config); }); @@ -760,6 +763,7 @@ describe("resolveWorldConfig", () => { namespace: "", namespaces: {}, } as const; + attest(config); }); @@ -868,11 +872,13 @@ describe("resolveWorldConfig", () => { namespace: "", namespaces: {}, } as const; + attest(config); }); it("should use the root namespace as default namespace", () => { const config = resolveWorldConfig({ tables: { Example: {} } }); + attest<"">(config.namespace); }); }); diff --git a/packages/world/ts/config/v2/world.ts b/packages/world/ts/config/v2/world.ts index de956466e9..5c96cc0d04 100644 --- a/packages/world/ts/config/v2/world.ts +++ b/packages/world/ts/config/v2/world.ts @@ -20,7 +20,7 @@ export type WorldConfigInput; +export type NamespaceInput = Pick; export type validateNamespaces = { [namespace in keyof input]: { diff --git a/templates/phaser/.vscode/settings.json b/templates/phaser/.vscode/settings.json index 0967ef424b..25fa6215fd 100644 --- a/templates/phaser/.vscode/settings.json +++ b/templates/phaser/.vscode/settings.json @@ -1 +1,3 @@ -{} +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/templates/react-ecs/.vscode/settings.json b/templates/react-ecs/.vscode/settings.json index 0967ef424b..25fa6215fd 100644 --- a/templates/react-ecs/.vscode/settings.json +++ b/templates/react-ecs/.vscode/settings.json @@ -1 +1,3 @@ -{} +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/templates/react/.vscode/settings.json b/templates/react/.vscode/settings.json index 0967ef424b..25fa6215fd 100644 --- a/templates/react/.vscode/settings.json +++ b/templates/react/.vscode/settings.json @@ -1 +1,3 @@ -{} +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/templates/threejs/.vscode/settings.json b/templates/threejs/.vscode/settings.json index 0967ef424b..25fa6215fd 100644 --- a/templates/threejs/.vscode/settings.json +++ b/templates/threejs/.vscode/settings.json @@ -1 +1,3 @@ -{} +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/templates/vanilla/.vscode/settings.json b/templates/vanilla/.vscode/settings.json index 0967ef424b..25fa6215fd 100644 --- a/templates/vanilla/.vscode/settings.json +++ b/templates/vanilla/.vscode/settings.json @@ -1 +1,3 @@ -{} +{ + "typescript.tsdk": "node_modules/typescript/lib" +}