Skip to content

Commit da1ef05

Browse files
ssalbdivadqbzzt
authored andcommitted
test: improve type benches with baseline + .ts files, avoiding build (#2988)
1 parent 9aafe06 commit da1ef05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+327
-148
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"sort-package-json": "npx sort-package-json package.json 'packages/*/package.json' 'templates/*/package.json' 'templates/*/packages/*/package.json' 'examples/*/package.json' 'examples/*/packages/*/package.json' 'e2e/*/package.json' 'e2e/*/packages/*/package.json' 'docs/package.json' 'test/*/package.json'",
3030
"test": "pnpm run --recursive test",
3131
"test:ci": "pnpm run --recursive --parallel test:ci",
32+
"type-bench": "pnpm --filter ./test/ts-benchmarks bench",
3233
"type-stats-repo": "attest stats packages/*"
3334
},
3435
"lint-staged": {
@@ -37,7 +38,7 @@
3738
"package.json": "pnpm sort-package-json"
3839
},
3940
"devDependencies": {
40-
"@arktype/attest": "0.7.5",
41+
"@ark/attest": "0.10.2",
4142
"@changesets/cli": "^2.27.7",
4243
"@types/node": "^18.15.11",
4344
"@typescript-eslint/eslint-plugin": "7.1.1",
@@ -56,9 +57,9 @@
5657
"turbo": "^1.9.3",
5758
"typescript": "5.4.2"
5859
},
59-
"packageManager": "pnpm@9.1.1",
60+
"packageManager": "pnpm@9.6.0",
6061
"engines": {
6162
"node": "^18.20.1",
62-
"pnpm": "^9.1.1"
63+
"pnpm": "^9.6.0"
6364
}
6465
}

packages/config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"test:ci": "pnpm run test"
4141
},
4242
"dependencies": {
43-
"@arktype/util": "0.0.40",
43+
"@ark/util": "catalog:",
4444
"@latticexyz/common": "workspace:*",
4545
"@latticexyz/schema-type": "workspace:*",
4646
"esbuild": "^0.17.15",

packages/config/src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Hex } from "viem";
22
import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type/internal";
33
import { ResourceType } from "@latticexyz/common";
4-
import { satisfy } from "@arktype/util";
4+
import { satisfy } from "@ark/util";
55

66
/**
77
* Common output types of a MUD config. We use these types as inputs for libraries.

packages/query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"test:ci": "pnpm run test"
3535
},
3636
"dependencies": {
37-
"@arktype/util": "0.0.40",
37+
"@ark/util": "catalog:",
3838
"@latticexyz/common": "workspace:*",
3939
"@latticexyz/config": "workspace:*",
4040
"@latticexyz/schema-type": "workspace:*",

packages/query/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Hex } from "viem";
2-
import { satisfy } from "@arktype/util";
2+
import { satisfy } from "@ark/util";
33
import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type/internal";
44
import { SchemaToPrimitives } from "@latticexyz/store/internal";
55
import { Table } from "@latticexyz/config";

packages/store-sync/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"test:ci": "vitest --run"
6363
},
6464
"dependencies": {
65-
"@arktype/util": "0.1.0",
65+
"@ark/util": "catalog:",
6666
"@latticexyz/block-logs-stream": "workspace:*",
6767
"@latticexyz/common": "workspace:*",
6868
"@latticexyz/config": "workspace:*",

packages/store-sync/src/common.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it } from "vitest";
2-
import { attest } from "@arktype/attest";
3-
import { isDisjoint } from "@arktype/util";
2+
import { attest } from "@ark/attest";
3+
import { isDisjoint } from "@ark/util";
44
import storeConfig from "@latticexyz/store/mud.config";
55
import worldConfig from "@latticexyz/world/mud.config";
66
import { configToTables } from "./configToTables";

packages/store-sync/src/configToTables.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it } from "vitest";
22
import { configToTables } from "./configToTables";
33
import { defineWorld } from "@latticexyz/world";
44
import { resourceToHex } from "@latticexyz/common";
5-
import { attest } from "@arktype/attest";
5+
import { attest } from "@ark/attest";
66

77
describe("configToTables", () => {
88
it("flattens tables from single namespace", async () => {

packages/store-sync/src/configToTables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { show } from "@arktype/util";
1+
import { show } from "@ark/util";
22
import { Store } from "@latticexyz/store";
33

44
type flattenedTableKeys<config extends Store> = config extends { readonly namespaces: infer namespaces }

packages/store-sync/src/recs/createStorageAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { hexKeyTupleToEntity } from "./hexKeyTupleToEntity";
1212
import { StorageAdapter, StorageAdapterBlock } from "../common";
1313
import { singletonEntity } from "./singletonEntity";
1414
import { tablesToComponents } from "./tablesToComponents";
15-
import { merge } from "@arktype/util";
15+
import { merge } from "@ark/util";
1616

1717
export type CreateStorageAdapterOptions<tables extends Tables> = {
1818
world: RecsWorld;

packages/store-sync/src/recs/syncToRecs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import { createStoreSync } from "../createStoreSync";
77
import { singletonEntity } from "./singletonEntity";
88
import { SyncStep } from "../SyncStep";
99
import { configToTables } from "../configToTables";
10-
import { merge } from "@arktype/util";
10+
import { merge } from "@ark/util";
1111

12-
export type SyncToRecsOptions<config extends StoreConfig, extraTables extends Tables> = Omit<SyncOptions, "config"> & {
12+
export type SyncToRecsOptions<config extends StoreConfig = StoreConfig, extraTables extends Tables = Tables> = Omit<
13+
SyncOptions,
14+
"config"
15+
> & {
1316
world: RecsWorld;
1417
config: config;
1518
tables?: extraTables;

packages/store-sync/src/recs/tablesToComponents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tables } from "@latticexyz/config";
22
import { tableToComponent } from "./tableToComponent";
33
import { World } from "@latticexyz/recs";
4-
import { show } from "@arktype/util";
4+
import { show } from "@ark/util";
55

66
export type tablesToComponents<tables extends Tables> = {
77
[label in keyof tables as tables[label]["label"]]: tableToComponent<tables[label]>;

packages/store-sync/src/zustand/syncToZustand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Address } from "viem";
77
import { SyncStep } from "../SyncStep";
88
import { Store as StoreConfig } from "@latticexyz/store";
99
import { Tables } from "@latticexyz/config";
10-
import { merge } from "@arktype/util";
10+
import { merge } from "@ark/util";
1111
import { configToTables } from "../configToTables";
1212

1313
export type SyncToZustandOptions<config extends StoreConfig, extraTables extends Tables> = Omit<

packages/store-sync/vitestSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { setup, cleanup as teardown } from "@arktype/attest";
1+
export { setup, cleanup as teardown } from "@ark/attest";

packages/store/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"test:ci": "pnpm run test"
6060
},
6161
"dependencies": {
62-
"@arktype/util": "0.0.40",
62+
"@ark/util": "catalog:",
6363
"@latticexyz/common": "workspace:*",
6464
"@latticexyz/config": "workspace:*",
6565
"@latticexyz/protocol-parser": "workspace:*",
@@ -69,7 +69,6 @@
6969
"viem": "2.9.20"
7070
},
7171
"devDependencies": {
72-
"@arktype/attest": "0.7.5",
7372
"@latticexyz/abi-ts": "workspace:*",
7473
"@latticexyz/gas-report": "workspace:*",
7574
"@types/ejs": "^3.1.1",

packages/store/ts/config/v2/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { flatMorph } from "@arktype/util";
1+
import { flatMorph } from "@ark/util";
22
import { EnumsInput } from "./input";
33
import { AbiTypeScope, extendScope } from "./scope";
44
import { parseNumber } from "./generics";

packages/store/ts/config/v2/flattenNamespacedTables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { show } from "@arktype/util";
1+
import { show } from "@ark/util";
22
import { Namespaces } from "./output";
33

44
type flattenNamespacedTableKeys<config> = config extends {

packages/store/ts/config/v2/namespace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorMessage, flatMorph } from "@arktype/util";
1+
import { ErrorMessage, flatMorph } from "@ark/util";
22
import { hasOwnKey, mergeIfUndefined } from "./generics";
33
import { NamespaceInput } from "./input";
44
import { resolveTables, validateTables } from "./tables";

packages/store/ts/config/v2/namespaces.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from "vitest";
2-
import { attest } from "@arktype/attest";
2+
import { attest } from "@ark/attest";
33
import { defineNamespaces } from "./namespaces";
44

55
describe("defineNamespaces", () => {

packages/store/ts/config/v2/namespaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { show, flatMorph } from "@arktype/util";
1+
import { show, flatMorph } from "@ark/util";
22
import { isObject, mergeIfUndefined } from "./generics";
33
import { NamespacesInput } from "./input";
44
import { AbiTypeScope, Scope } from "./scope";

packages/store/ts/config/v2/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { show } from "@arktype/util";
1+
import { show } from "@ark/util";
22
import { AbiType, Schema, Table as BaseTable } from "@latticexyz/config";
33
import { EnumsInput } from "./input";
44

packages/store/ts/config/v2/schema.test.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it } from "vitest";
22
import { defineSchema } from "./schema";
33
import { Schema } from "./output";
44
import { extendScope, AbiTypeScope } from "./scope";
5-
import { attest } from "@arktype/attest";
5+
import { attest } from "@ark/attest";
66

77
describe("resolveSchema", () => {
88
it("should map user types to their primitive type", () => {
@@ -19,11 +19,16 @@ describe("resolveSchema", () => {
1919
},
2020
} as const;
2121

22-
attest<typeof expected>(resolved)
23-
.equals(expected)
24-
.type.toString.snap(
25-
'{ readonly regular: { readonly type: "uint256"; readonly internalType: "uint256"; }; readonly user: { readonly type: "address"; readonly internalType: "CustomType"; }; }',
26-
);
22+
attest<typeof expected>(resolved).equals(expected).type.toString.snap(`{
23+
readonly regular: {
24+
readonly type: "uint256"
25+
readonly internalType: "uint256"
26+
}
27+
readonly user: {
28+
readonly type: "address"
29+
readonly internalType: "CustomType"
30+
}
31+
}`);
2732
});
2833

2934
it("should throw if a type is not part of the scope", () => {
@@ -57,8 +62,11 @@ describe("resolveSchema", () => {
5762
},
5863
} as const;
5964

60-
attest<typeof expected>(resolved)
61-
.equals(expected)
62-
.type.toString.snap('{ readonly coordinate: { readonly type: "int32[]"; readonly internalType: "int32[2]"; }; }');
65+
attest<typeof expected>(resolved).equals(expected).type.toString.snap(`{
66+
readonly coordinate: {
67+
readonly type: "int32[]"
68+
readonly internalType: "int32[2]"
69+
}
70+
}`);
6371
});
6472
});

packages/store/ts/config/v2/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { conform, show } from "@arktype/util";
1+
import { conform, show } from "@ark/util";
22
import { AbiTypeScope, Scope } from "./scope";
33
import { hasOwnKey, isObject } from "./generics";
44
import { SchemaInput } from "./input";

packages/store/ts/config/v2/scope.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import { attest } from "@arktype/attest";
1+
import { attest } from "@ark/attest";
22
import { describe, it } from "vitest";
33
import { AbiTypeScope, Scope, ScopeOptions, extendScope, getStaticAbiTypeKeys } from "./scope";
44

55
describe("extendScope", () => {
66
it("should extend the provided scope", () => {
77
const extendedScope = extendScope(Scope, { static: "uint256", dynamic: "string" });
88
attest<ScopeOptions<{ static: "uint256"; dynamic: "string" }>>(extendedScope).type.toString.snap(
9-
'{ types: { static: "uint256"; dynamic: "string"; }; }',
9+
'{ types: { static: "uint256"; dynamic: "string" } }',
1010
);
1111

1212
const furtherExtendedScope = extendScope(extendedScope, { static2: "uint256", dynamic2: "string" });
1313
attest<ScopeOptions<{ static: "uint256"; dynamic: "string"; static2: "uint256"; dynamic2: "string" }>>(
1414
furtherExtendedScope,
15-
).type.toString.snap(
16-
'{ types: { static: "uint256"; dynamic: "string"; static2: "uint256"; dynamic2: "string"; }; }',
17-
);
15+
).type.toString.snap(`{
16+
types: {
17+
static: "uint256"
18+
dynamic: "string"
19+
static2: "uint256"
20+
dynamic2: "string"
21+
}
22+
}`);
1823
});
1924
});
2025

packages/store/ts/config/v2/scope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dict, show } from "@arktype/util";
1+
import { Dict, show } from "@ark/util";
22
import { SchemaInput } from "./input";
33
import { StaticAbiType, schemaAbiTypes } from "@latticexyz/schema-type/internal";
44
import { AbiType } from "./output";

packages/store/ts/config/v2/store.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { describe, it } from "vitest";
22
import { defineStore } from "./store";
3-
import { attest } from "@arktype/attest";
3+
import { attest } from "@ark/attest";
44
import { resourceToHex } from "@latticexyz/common";
55
import { Store } from "./output";
6-
import { satisfy } from "@arktype/util";
6+
import { satisfy } from "@ark/util";
77
import { Hex } from "viem";
88

99
describe("defineStore", () => {

packages/store/ts/config/v2/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorMessage, show, narrow } from "@arktype/util";
1+
import { ErrorMessage, show, narrow } from "@ark/util";
22
import { get, hasOwnKey } from "./generics";
33
import { UserTypes } from "./output";
44
import { CONFIG_DEFAULTS } from "./defaults";

packages/store/ts/config/v2/table.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { attest } from "@arktype/attest";
1+
import { attest } from "@ark/attest";
22
import { describe, it } from "vitest";
33
import { getStaticAbiTypeKeys, AbiTypeScope, extendScope } from "./scope";
44
import { validateKeys, defineTable } from "./table";

packages/store/ts/config/v2/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorMessage, conform, show, narrow, requiredKeyOf } from "@arktype/util";
1+
import { ErrorMessage, conform, show, narrow, requiredKeyOf } from "@ark/util";
22
import { isStaticAbiType } from "@latticexyz/schema-type/internal";
33
import { Hex } from "viem";
44
import { get, hasOwnKey, mergeIfUndefined } from "./generics";

packages/store/ts/config/v2/tableShorthand.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from "vitest";
2-
import { attest } from "@arktype/attest";
2+
import { attest } from "@ark/attest";
33
import { AbiTypeScope, extendScope } from "./scope";
44
import { NoStaticKeyFieldError, defineTableShorthand } from "./tableShorthand";
55

packages/store/ts/config/v2/tableShorthand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { hasOwnKey, isObject } from "./generics";
33
import { SchemaInput, ScopedSchemaInput, TableShorthandInput } from "./input";
44
import { isSchemaInput } from "./schema";
55
import { AbiTypeScope, Scope, getStaticAbiTypeKeys } from "./scope";
6-
import { ErrorMessage, conform } from "@arktype/util";
6+
import { ErrorMessage, conform } from "@ark/util";
77

88
export const NoStaticKeyFieldError =
99
"Invalid schema. Expected an `id` field with a static ABI type or an explicit `key` option.";

packages/store/ts/config/v2/tables.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from "vitest";
2-
import { attest } from "@arktype/attest";
2+
import { attest } from "@ark/attest";
33
import { AbiTypeScope, extendScope } from "./scope";
44
import { defineTables, validateTables } from "./tables";
55

packages/store/ts/config/v2/tables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorMessage, show } from "@arktype/util";
1+
import { ErrorMessage, show } from "@ark/util";
22
import { isObject, mergeIfUndefined } from "./generics";
33
import { TableShorthandInput, TablesInput } from "./input";
44
import { Scope, AbiTypeScope } from "./scope";

packages/store/vitestSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { setup, cleanup as teardown } from "@arktype/attest";
1+
export { setup, cleanup as teardown } from "@ark/attest";

packages/world/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"test:ci": "pnpm run test"
6060
},
6161
"dependencies": {
62-
"@arktype/util": "0.0.40",
62+
"@ark/util": "catalog:",
6363
"@latticexyz/common": "workspace:*",
6464
"@latticexyz/config": "workspace:*",
6565
"@latticexyz/protocol-parser": "workspace:*",
@@ -70,7 +70,6 @@
7070
"viem": "2.9.20"
7171
},
7272
"devDependencies": {
73-
"@arktype/attest": "0.7.5",
7473
"@latticexyz/abi-ts": "workspace:*",
7574
"@latticexyz/gas-report": "workspace:*",
7675
"@types/ejs": "^3.1.1",

packages/world/ts/config/v2/namespaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { show, flatMorph } from "@arktype/util";
1+
import { show, flatMorph } from "@ark/util";
22
import { NamespacesInput } from "./input";
33
import { validateNamespace, resolveNamespace } from "./namespace";
44
import { groupBy } from "@latticexyz/common/utils";

packages/world/ts/config/v2/system.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from "vitest";
2-
import { attest } from "@arktype/attest";
2+
import { attest } from "@ark/attest";
33
import { resourceToHex } from "@latticexyz/common";
44
import { defineSystem } from "./system";
55
import { SYSTEM_DEFAULTS } from "./defaults";

packages/world/ts/config/v2/system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SYSTEM_DEFAULTS } from "./defaults";
22
import { SystemInput } from "./input";
33
import { hasOwnKey, mergeIfUndefined } from "@latticexyz/store/config/v2";
4-
import { ErrorMessage, narrow, requiredKeyOf } from "@arktype/util";
4+
import { ErrorMessage, narrow, requiredKeyOf } from "@ark/util";
55
import { Hex } from "viem";
66
import { resourceToHex } from "@latticexyz/common";
77

packages/world/ts/config/v2/systems.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorMessage } from "@arktype/util";
1+
import { ErrorMessage } from "@ark/util";
22
import { isObject } from "@latticexyz/store/config/v2";
33
import { SystemsInput } from "./input";
44
import { resolveSystem, validateSystem } from "./system";

0 commit comments

Comments
 (0)