@ark/attest 0.58.1 → 0.59.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/out/assert/assertions.d.ts +1 -0
- package/out/assert/assertions.js +82 -21
- package/out/assert/chainableAssertions.js +2 -3
- package/out/bench/baseline.js +2 -1
- package/out/bench/bench.d.ts +2 -3
- package/out/bench/bench.js +67 -27
- package/out/cache/snapshots.js +3 -2
- package/out/cache/utils.js +24 -2
- package/out/cli/shared.d.ts +1 -1
- package/out/cli/shared.js +16 -1
- package/out/cli/stats.js +2 -6
- package/out/cli/trace.js +3 -3
- package/out/config.js +8 -8
- package/out/index.d.ts +2 -1
- package/out/index.js +1 -0
- package/out/ts7/analyze.js +5 -2
- package/out/ts7/countInstantiations.js +17 -2
- package/out/ts7/instantiations.js +62 -8
- package/package.json +5 -5
- package/out/bench/await1k.d.ts +0 -1
- package/out/bench/await1k.js +0 -1002
- package/out/bench/call1k.d.ts +0 -1
- package/out/bench/call1k.js +0 -1002
|
@@ -19,15 +19,68 @@ export const getInstantiationsContributedByNodes = (file, blocks) => {
|
|
|
19
19
|
if (!blocks.length)
|
|
20
20
|
return [];
|
|
21
21
|
const baselineText = getBaselineText(file);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
];
|
|
22
|
+
const unforced = blocks.map(block => `${baselineText}\nconst $attestIsolatedBench = ${block.getFullText()}`);
|
|
23
|
+
// the forcing syntax isn't valid JS, and a generic block's result would be
|
|
24
|
+
// inferred from constraints it's never called with
|
|
25
|
+
const canForce = /\.[cm]?tsx?$/.test(file.fileName);
|
|
26
|
+
const [baseline, ...results] = countVariants(file, [
|
|
27
|
+
{ text: baselineText, noErrorTruncation: true },
|
|
28
|
+
...blocks.map((block, i) => ({
|
|
29
|
+
text: canForce && !block.typeParameters?.length ?
|
|
30
|
+
unforced[i] + forceResult
|
|
31
|
+
: unforced[i],
|
|
32
|
+
noErrorTruncation: true
|
|
33
|
+
}))
|
|
34
|
+
]);
|
|
35
|
+
const counts = results.map(result => result.count - baseline.count);
|
|
36
|
+
// noErrorTruncation also writes out a block's own errors in full, so a block
|
|
37
|
+
// with errors is counted without it, plus what forcing its result adds
|
|
38
|
+
const blockStart = baselineText.split("\n").length + 1;
|
|
39
|
+
const withErrors = blocks.flatMap((block, i) => {
|
|
40
|
+
const blockText = block.getFullText();
|
|
41
|
+
const blockEnd = blockStart + blockText.split("\n").length - 1;
|
|
42
|
+
const hasErrors =
|
|
43
|
+
// suppressed errors are still written out but not reported
|
|
44
|
+
/@ts-(expect-error|ignore)/.test(blockText) ||
|
|
45
|
+
results[i].errorLines.some(line => line >= blockStart && line <= blockEnd);
|
|
46
|
+
return hasErrors ? [i] : [];
|
|
47
|
+
});
|
|
48
|
+
if (!withErrors.length)
|
|
49
|
+
return counts;
|
|
50
|
+
const [truncatedBaseline, ...unforcedResults] = countVariants(file, [
|
|
51
|
+
{ text: baselineText, noErrorTruncation: false },
|
|
52
|
+
...withErrors.flatMap(i => [
|
|
53
|
+
{ text: unforced[i], noErrorTruncation: false },
|
|
54
|
+
{ text: unforced[i], noErrorTruncation: true }
|
|
55
|
+
])
|
|
56
|
+
]);
|
|
57
|
+
for (const [j, i] of withErrors.entries()) {
|
|
58
|
+
const truncated = unforcedResults[2 * j].count - truncatedBaseline.count;
|
|
59
|
+
const untruncated = unforcedResults[2 * j + 1].count - baseline.count;
|
|
60
|
+
counts[i] = truncated + counts[i] - untruncated;
|
|
61
|
+
}
|
|
62
|
+
return counts;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* TS only evaluates the members of many types, e.g. mapped types, once
|
|
66
|
+
* something reads them. Passing a block's result type where `never` is
|
|
67
|
+
* required makes tsc write it into an error in full (given
|
|
68
|
+
* `noErrorTruncation`), so it's counted as if it were displayed without
|
|
69
|
+
* adding anything for types that were already evaluated.
|
|
70
|
+
*
|
|
71
|
+
* Assigning the result to `never` would also check whether a callable
|
|
72
|
+
* result's return type fits, counting work that displaying it wouldn't do.
|
|
73
|
+
*/
|
|
74
|
+
const forceResult = `
|
|
75
|
+
const $attestIsolatedResult = $attestIsolatedBench()
|
|
76
|
+
declare function $attestIsolate<t extends never>(): void
|
|
77
|
+
$attestIsolate<typeof $attestIsolatedResult>()`;
|
|
78
|
+
const countVariants = (file, variants) => {
|
|
26
79
|
const { projectConfig } = TsgoServer.instance;
|
|
27
80
|
const fileDir = dirname(file.fileName);
|
|
28
81
|
const fileBase = basename(file.fileName);
|
|
29
82
|
const files = {};
|
|
30
|
-
const configPaths = variants.map((text, i) => {
|
|
83
|
+
const configPaths = variants.map(({ text, noErrorTruncation }, i) => {
|
|
31
84
|
// dot-prefixed so test runner globs don't pick it up
|
|
32
85
|
const sourcePath = join(fileDir, `.attest-${tempId}-${i}-${fileBase}`);
|
|
33
86
|
const configPath = join(projectConfig.dir, `.attest-${tempId}-${i}.tsconfig.json`);
|
|
@@ -50,19 +103,20 @@ export const getInstantiationsContributedByNodes = (file, blocks) => {
|
|
|
50
103
|
// a bench excluded from the project may be outside its rootDir
|
|
51
104
|
rootDir: null,
|
|
52
105
|
// otherwise counts depend on whether declarations are checked
|
|
53
|
-
skipLibCheck: true
|
|
106
|
+
skipLibCheck: true,
|
|
107
|
+
// see forceResult
|
|
108
|
+
noErrorTruncation
|
|
54
109
|
},
|
|
55
110
|
files: [sourcePath],
|
|
56
111
|
include: []
|
|
57
112
|
});
|
|
58
113
|
return configPath;
|
|
59
114
|
});
|
|
60
|
-
|
|
115
|
+
return JSON.parse(execFileSync(process.execPath, [countInstantiationsScript, getTscPath()], {
|
|
61
116
|
input: JSON.stringify({ files, configPaths }),
|
|
62
117
|
encoding: "utf8",
|
|
63
118
|
maxBuffer: 1e8
|
|
64
119
|
}));
|
|
65
|
-
return counts.map(count => count - baseline);
|
|
66
120
|
};
|
|
67
121
|
const getBaselineText = (file) => {
|
|
68
122
|
const text = file.getFullText();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.0-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Blass",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@typescript/analyze-trace": "0.10.1",
|
|
41
41
|
"@typescript/vfs": "1.6.1",
|
|
42
42
|
"prettier": "3.6.2",
|
|
43
|
-
"@ark/fs": "0.
|
|
44
|
-
"@ark/schema": "0.
|
|
45
|
-
"@ark/util": "0.
|
|
46
|
-
"arktype": "
|
|
43
|
+
"@ark/fs": "0.57.0-beta.0",
|
|
44
|
+
"@ark/schema": "0.57.0-beta.0",
|
|
45
|
+
"@ark/util": "0.57.0-beta.0",
|
|
46
|
+
"arktype": "3.0.0-beta.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsrs": "0.18.0-ts7.1.0-dev.20260929",
|
package/out/bench/await1k.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const await1K: (fn: () => Promise<void>) => Promise<void>;
|