Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
5ae2799
improve structural
ssalbdivad Apr 18, 2025
8922b40
continuuu
ssalbdivad Apr 18, 2025
77a2899
ok
ssalbdivad Apr 18, 2025
9000ded
ok
ssalbdivad Apr 18, 2025
79fc458
having fn
ssalbdivad Apr 19, 2025
8674400
add fn tests
ssalbdivad Apr 19, 2025
250348e
tests
ssalbdivad Apr 19, 2025
5093b28
continuuu
ssalbdivad Apr 19, 2025
e226dd4
add expression
ssalbdivad Apr 19, 2025
b871511
bench
ssalbdivad Apr 19, 2025
fc12a09
fun iter
ssalbdivad Apr 19, 2025
1bbb435
good
ssalbdivad Apr 19, 2025
1af6a98
finish signatures
ssalbdivad Apr 19, 2025
abb94cb
nice
ssalbdivad Apr 19, 2025
ec5dd06
continuuu
ssalbdivad Apr 19, 2025
b856c9a
ok
ssalbdivad Apr 19, 2025
47dedae
fix type tests
ssalbdivad Apr 19, 2025
1a3e950
cook
ssalbdivad Apr 19, 2025
bada064
big
ssalbdivad Apr 19, 2025
2ed9180
seems ok
ssalbdivad Apr 19, 2025
8876435
uhhhh no errors in tests?
ssalbdivad Apr 19, 2025
d408285
continuuuuuuuuuuuuuuuuuuuuuuuuuuuu
ssalbdivad Apr 19, 2025
18b806d
ok ok ok ok ok ok ok
ssalbdivad Apr 19, 2025
d01fe7d
mama
ssalbdivad Apr 19, 2025
a50618e
fix fix
ssalbdivad Apr 19, 2025
1f1f080
1 cache issue
ssalbdivad Apr 19, 2025
b2aea55
tests fixed
ssalbdivad Apr 20, 2025
96f6c20
bench
ssalbdivad Apr 20, 2025
c17277c
ok
ssalbdivad Apr 20, 2025
4a47b52
ok
ssalbdivad Apr 20, 2025
ad3665b
fix tests
ssalbdivad Apr 20, 2025
e21b50e
ok okok
ssalbdivad Apr 20, 2025
a520ffd
declare morph
ssalbdivad Apr 20, 2025
fd5c5d5
finish declare docs
ssalbdivad Apr 20, 2025
fecf900
add llms txt
ssalbdivad Apr 21, 2025
e6425bb
ok
ssalbdivad Apr 21, 2025
04b58ba
ok
ssalbdivad Apr 21, 2025
297af21
huh
ssalbdivad Apr 21, 2025
d144687
ok
ssalbdivad Apr 21, 2025
265febe
ok
ssalbdivad Apr 21, 2025
bb75a08
big select docs
ssalbdivad Apr 21, 2025
9f61e03
okokokokok
ssalbdivad Apr 21, 2025
93dabf7
wowowwowowoowo
ssalbdivad Apr 21, 2025
60c0ec0
fix tests
ssalbdivad Apr 21, 2025
b090551
actual fixo
ssalbdivad Apr 22, 2025
d02e8a2
ok
ssalbdivad Apr 22, 2025
bbd70a4
begin integrating regex
ssalbdivad Apr 22, 2025
8442044
iter
ssalbdivad Apr 22, 2025
bab9b82
huh
ssalbdivad Apr 23, 2025
7e68073
improv
ssalbdivad Apr 23, 2025
d97e1e9
le cont
ssalbdivad Apr 23, 2025
f96e8a5
ok
ssalbdivad Apr 23, 2025
76e2556
moar
ssalbdivad Apr 23, 2025
fa20cdd
wow
ssalbdivad Apr 23, 2025
6af3951
fixo
ssalbdivad Apr 23, 2025
ccf065f
big big big big big bigbig big
ssalbdivad Apr 23, 2025
ccd00df
removio
ssalbdivad Apr 23, 2025
fa3eaca
huh
ssalbdivad Apr 23, 2025
3314247
fix inter
ssalbdivad Apr 23, 2025
a53a80d
ok ok ok ok ok ok ok
ssalbdivad Apr 23, 2025
471c322
okokok
ssalbdivad Apr 23, 2025
ee750a8
try
ssalbdivad Apr 24, 2025
459d563
try
ssalbdivad Apr 24, 2025
98598cc
hmm
ssalbdivad Apr 24, 2025
539e6d4
ok
ssalbdivad Apr 24, 2025
4985c66
ok
ssalbdivad Apr 24, 2025
38c6074
ok
ssalbdivad Apr 24, 2025
c3f7f1d
ok
ssalbdivad Apr 24, 2025
2e32f83
ok
ssalbdivad Apr 24, 2025
6f30083
ok
ssalbdivad Apr 25, 2025
2daecd3
ok
ssalbdivad Apr 25, 2025
b109dc3
huh
ssalbdivad Apr 25, 2025
77af6ea
ranges
ssalbdivad Apr 25, 2025
77d4c8d
ranges
ssalbdivad Apr 25, 2025
071b354
up ext
ssalbdivad Apr 25, 2025
7d1f7e8
Merge branch 'main' into 21
ssalbdivad Apr 25, 2025
a5f6d69
loop
ssalbdivad Apr 25, 2025
64740f3
blah
ssalbdivad Apr 25, 2025
7c1bb9e
continuuu
ssalbdivad Apr 25, 2025
74201ca
fix playground
ssalbdivad Apr 28, 2025
86b1ef1
iterate on escape
ssalbdivad Apr 28, 2025
8574e93
ok
ssalbdivad Apr 28, 2025
bd06bb7
ok
ssalbdivad Apr 29, 2025
5bd1e5a
fix error scaling
ssalbdivad Apr 29, 2025
257dd6b
fix overlapping match ctx
ssalbdivad Apr 29, 2025
40110aa
fix more match types
ssalbdivad Apr 29, 2025
6153d25
continuuu
ssalbdivad Apr 29, 2025
dc1c27c
try
ssalbdivad Apr 29, 2025
c910b35
iter
ssalbdivad Apr 29, 2025
2e0ff07
continuu
ssalbdivad Apr 29, 2025
79a8296
improv
ssalbdivad Apr 29, 2025
f236151
ok
ssalbdivad Apr 29, 2025
498272d
fix builds, bump deps
ssalbdivad Apr 30, 2025
5da94cc
ok
ssalbdivad Apr 30, 2025
a99150a
ok
ssalbdivad Apr 30, 2025
953eddb
continuu
ssalbdivad Apr 30, 2025
19fa29d
ok
ssalbdivad Apr 30, 2025
c512afa
moar
ssalbdivad Apr 30, 2025
808d364
ok
ssalbdivad Apr 30, 2025
ef2d1f5
ok
ssalbdivad May 1, 2025
1a3413f
continuuu
ssalbdivad May 1, 2025
70349ad
parse parse
ssalbdivad May 1, 2025
4a577a2
missing flags, unification
ssalbdivad May 1, 2025
72b38d8
okokok
ssalbdivad May 1, 2025
47190a4
try
ssalbdivad May 1, 2025
3a54bf0
fix highlight
ssalbdivad May 1, 2025
dc37f6a
all features
ssalbdivad May 1, 2025
1e31d51
pumpaupmp
ssalbdivad May 1, 2025
65b3dc4
o
ssalbdivad May 1, 2025
dc0807f
rename
ssalbdivad May 1, 2025
f32e3b9
try
ssalbdivad May 1, 2025
90ca257
ok
ssalbdivad May 1, 2025
88dd7e9
finish rewriting tree
ssalbdivad May 2, 2025
2a549d9
ok
ssalbdivad May 2, 2025
9b95923
ggwp
ssalbdivad May 2, 2025
7c00979
opt
ssalbdivad May 2, 2025
3f7c7f9
trying
ssalbdivad May 2, 2025
0645b1e
ok
ssalbdivad May 2, 2025
4d967ae
fix bug
ssalbdivad May 2, 2025
05091e4
fix
ssalbdivad May 2, 2025
db0cc07
depth nodes
ssalbdivad May 2, 2025
736170e
nice
ssalbdivad May 2, 2025
e058438
ok
ssalbdivad May 2, 2025
6baf77d
it
ssalbdivad May 2, 2025
48bff7f
benchup
ssalbdivad May 2, 2025
4af0dfa
dts
ssalbdivad May 2, 2025
0dda238
ok
ssalbdivad May 3, 2025
c71ec09
big
ssalbdivad May 3, 2025
41d0d64
try
ssalbdivad May 3, 2025
60bc6b0
remove dumb try
ssalbdivad May 20, 2025
f0c58b1
improve README
ssalbdivad May 20, 2025
e04d6d3
hmm
ssalbdivad Jun 2, 2025
5b138c9
improve tracing
ssalbdivad Jun 3, 2025
ae603bd
bump version
ssalbdivad Jun 5, 2025
65ef8bc
add trace progress
ssalbdivad Jun 3, 2025
f31acf0
bump
Jun 6, 2025
57f9c5f
finalize finalize finalize finalize
ssalbdivad Jun 11, 2025
5ce2e06
iterate on depth
ssalbdivad Jun 20, 2025
56dd16b
huh
ssalbdivad Jun 26, 2025
7cacf45
hmmm
ssalbdivad Jun 27, 2025
cdd0942
improv
ssalbdivad Jul 3, 2025
91ba07d
get out of the hottub
ssalbdivad Jul 8, 2025
d8d833d
fix de tests MONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
ssalbdivad Jul 8, 2025
e7d0300
cast away problems
ssalbdivad Jul 9, 2025
0b69954
update benches
ssalbdivad Jul 9, 2025
cf939e4
pre capture refactor
ssalbdivad Jul 9, 2025
c6c1683
update capture group representation
ssalbdivad Jul 9, 2025
8e49f58
work on regex interface
ssalbdivad Jul 11, 2025
a7cf75c
ok
ssalbdivad Jul 11, 2025
afcc3d3
pre-flagenation
ssalbdivad Jul 17, 2025
bdff58b
continuuuuuuuyyuuyuuu
ssalbdivad Jul 17, 2025
ab80459
param variants
ssalbdivad Jul 17, 2025
44e31af
RegexContext parameter
ssalbdivad Jul 24, 2025
4d3ef1d
fix tests
ssalbdivad Jul 24, 2025
056e613
update snapshots
ssalbdivad Jul 24, 2025
bd89e6f
update snapshots
ssalbdivad Jul 24, 2025
1638e4c
add 4d chess solution
ssalbdivad Jul 24, 2025
3b08865
simplify exec array types
ssalbdivad Jul 24, 2025
9266185
add comment
ssalbdivad Jul 24, 2025
799ac98
add test
ssalbdivad Jul 30, 2025
722987e
add some notes
ssalbdivad Jul 30, 2025
b875d47
experiment closedGroups
ssalbdivad Jul 30, 2025
a03cc78
fonzi
ssalbdivad Aug 7, 2025
7f1fd93
things gon get bad up in her
ssalbdivad Aug 7, 2025
326c89f
start breaking
ssalbdivad Aug 7, 2025
6a5a0ee
comtinuuu
ssalbdivad Aug 7, 2025
3e05c15
iterate
ssalbdivad Aug 15, 2025
a8483ed
fix captures hover
ssalbdivad Aug 15, 2025
23eb2f7
clean
ssalbdivad Aug 15, 2025
ceaa92d
HUGEEEEEEEEEEE
ssalbdivad Aug 15, 2025
820c154
fix validation
ssalbdivad Aug 15, 2025
bd7a5ad
BIGBIGIBIGIBIGIBIGIBIGIIIGG GIGAS TEXIDORE IVVIVIVIVIVIVIVIVIV
ssalbdivad Aug 15, 2025
741a40e
20
ssalbdivad Aug 20, 2025
bc01e72
19
ssalbdivad Aug 20, 2025
655f638
prequantifyyyy
ssalbdivad Aug 20, 2025
b7ba0db
start breaking quantifiers
ssalbdivad Aug 20, 2025
9f32585
add example to tests
ssalbdivad Aug 22, 2025
ee26509
remove depth
ssalbdivad Aug 22, 2025
b04235d
initial quantify implementation
ssalbdivad Aug 22, 2025
a60bb83
work on quantification
ssalbdivad Aug 22, 2025
90883ed
quantify bettet 0
ssalbdivad Aug 22, 2025
50dba81
improve refs
ssalbdivad Aug 23, 2025
85d3ec3
continuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu…
ssalbdivad Aug 23, 2025
17647d5
eh
ssalbdivad Aug 23, 2025
fcde1eb
BIG FIXO FIXO jajajajajaja
ssalbdivad Aug 23, 2025
3079416
fix fix fix fix fix
ssalbdivad Aug 23, 2025
a8463e8
iter iter
ssalbdivad Aug 25, 2025
65337b2
fix bug
ssalbdivad Aug 27, 2025
8c17ecd
pre-bail
ssalbdivad Aug 31, 2025
3fcc96e
add
ssalbdivad Aug 31, 2025
0a61a2f
hmm
ssalbdivad Aug 31, 2025
862399f
ok
ssalbdivad Sep 4, 2025
6def988
merge main
ssalbdivad Sep 4, 2025
4b14523
HOLYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY…
ssalbdivad Sep 4, 2025
80eef60
SERIOUS PROGRESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
ssalbdivad Sep 4, 2025
2ebcfce
HOW IT STARTED: 😵 HOW IT'S GOING: 📈
ssalbdivad Sep 4, 2025
6d7bb27
more more moremormoemoremormoemore
ssalbdivad Sep 4, 2025
4888a70
fixxxxxxxx
ssalbdivad Sep 6, 2025
a65a9ba
continuu
ssalbdivad Sep 6, 2025
42ca58b
ez do some refactors ez
ssalbdivad Sep 6, 2025
aeec826
begin refactor
ssalbdivad Sep 6, 2025
36ccb3a
iterate
ssalbdivad Sep 6, 2025
25909ec
okokokokokokok improve
ssalbdivad Sep 6, 2025
b066e02
improve
ssalbdivad Sep 7, 2025
af7f3fe
ffffffffffffffffffffffffffffffff
ssalbdivad Sep 7, 2025
bfb5fe9
fix fix okokokko
ssalbdivad Sep 7, 2025
9e8325b
cleanup
ssalbdivad Sep 8, 2025
1a0b348
bench up
ssalbdivad Sep 8, 2025
38513d2
improve bench
ssalbdivad Sep 8, 2025
ee42814
big fixy
ssalbdivad Sep 8, 2025
78dfb89
add semver test
ssalbdivad Sep 8, 2025
05c4032
improv
ssalbdivad Sep 10, 2025
e48c8b0
bench
ssalbdivad Sep 10, 2025
edffcad
improv
ssalbdivad Sep 10, 2025
6e656f9
ok
ssalbdivad Sep 10, 2025
77e8924
more improve
ssalbdivad Sep 10, 2025
89e3c2e
optimize
ssalbdivad Sep 10, 2025
c846522
improv
ssalbdivad Sep 10, 2025
3c131b2
iterate on benches
ssalbdivad Sep 10, 2025
b6fa062
big opt
ssalbdivad Sep 10, 2025
8342067
yeah
ssalbdivad Sep 11, 2025
82b572f
ok
ssalbdivad Sep 11, 2025
8192da6
work on README for regex
ssalbdivad Sep 11, 2025
7c6f2c4
add capture groups
ssalbdivad Sep 11, 2025
4113b64
ok
ssalbdivad Sep 17, 2025
bc64348
update benches
ssalbdivad Sep 21, 2025
413f2bb
fix type error
ssalbdivad Sep 21, 2025
90fa648
fix import
ssalbdivad Sep 21, 2025
aa182ee
okokok
ssalbdivad Sep 21, 2025
624ebf6
strip
ssalbdivad Sep 26, 2025
5ab0aec
ok
ssalbdivad Oct 6, 2025
32a7a24
Merge branch 'main' into depth-nodes
ssalbdivad Oct 12, 2025
0621d3e
optimize
ssalbdivad Oct 14, 2025
c6f18b6
fix tests
ssalbdivad Oct 14, 2025
a8b71b8
fix tests, docs
ssalbdivad Oct 14, 2025
da03388
fix
ssalbdivad Oct 14, 2025
7026765
fix tests
ssalbdivad Oct 14, 2025
9e6cbce
update benches
ssalbdivad Oct 14, 2025
29b882e
merge main
ssalbdivad Oct 14, 2025
0803ea6
fix docs typo
ssalbdivad Oct 14, 2025
10572ca
bump versions
ssalbdivad Oct 14, 2025
180b04d
update changelog
ssalbdivad Oct 14, 2025
0176cca
fix lockfile
ssalbdivad Oct 14, 2025
1a06771
only run modifier regex tests in node
ssalbdivad Oct 14, 2025
985e234
remove 24 KEKW
ssalbdivad Oct 14, 2025
a16c682
workaround failOnMissingSnapshots for CI in population test
ssalbdivad Oct 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ git checkout -b amazing-feature
```

6. Do your best to write code that is stylistically consistent with its context. The linter will help with this, but it won't catch everything. Here's a few general guidelines:

- Favor mutation over copying objects in perf-sensitive contexts
- Favor clarity in naming with the following exceptions:
- Ubiquitous variables/types. For example, use `s` over `dynamicParserState` for a variable of type DynamicParserState that is used in the same way across many functions.
Expand All @@ -56,13 +55,11 @@ git checkout -b amazing-feature
We also have some unique casing rules for our TypeScript types to facilitate type-level code that can parallel its runtime implementation and be easily understood:

- Use `PascalCase` for...

- Entities/non-generic types (e.g. `User`, `SomeData`)
- Generic types with noun names, like `Array<t>`. As a rule of thumb, your generic should be named this way if all its parameters have defaults (unfortunately TS's built-in `Array` type doesn't have a default parameter, but it probably should have been `unknown`!)
- Generic types with noun names, like `Array<t>`. As a rule of thumb, if your generic is named this way, all parameters have defaults.

- Use `camelCase` for...

- Generic types with verb names like `inferDomain<t>`. Types named this way should generally have at least one required parameter.
- Generic types with verb names like `inferDomain<t>`. Types named this way have at least one required parameter.
- Parameter names, e.g. `t` in `Array<t>`

7. Once you've made the changes you want to and added corresponding unit tests, run the `prChecks` command in the project root and address any errors:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ tmp
.attest
tsconfig.build.json
coverage
# we avoid committing the root pnpm-lock in order to keep the root of the repo as clean as possible.
# we can get away with this to since we're only installing devDependencies and they're all pinned.
/pnpm-lock.yaml
10 changes: 6 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
"ATTEST_skipTypes": "true"
},
"testExplorer.useNativeTesting": true,
"editor.unicodeHighlight.allowedCharacters": {
// Hair Space: used as a sentinel for error messages
" ": true
},
"search.exclude": {
"**/out": true,
"**/.next": true,
Expand All @@ -50,5 +46,11 @@
},
"editor.quickSuggestions": {
"strings": "on"
},
"github.copilot.enable": {
"*": false,
"plaintext": false,
"markdown": false,
"scminput": false
}
}
4 changes: 4 additions & 0 deletions ark/attest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

NOTE: This changelog is incomplete, but will include notable attest-specific changes (many updates consist almost entirely of bumped `arktype` versions for assertions).

## 0.47.0

Add a `failOnMissingSnapshots` config option. Defaults to `true` if `CI` is set in your environment, `false` otherwise.

## 0.46.0

Fix an issue causing some bench files to not be parsed correctly, leading to errors and 0 instantiation counts.
Expand Down
10 changes: 10 additions & 0 deletions ark/attest/__tests__/assertions.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { attest } from "@ark/attest"
import { MissingSnapshotError } from "@ark/attest/internal/assert/assertions.js"
import { attestInternal } from "@ark/attest/internal/assert/attest.js"
import { type } from "arktype"
import * as assert from "node:assert/strict"

Expand Down Expand Up @@ -201,4 +203,12 @@ Actual: [ArkError]`)
"BAR"
)
})

it("failOnMissingSnapshots", () => {
assert.throws(
() =>
attestInternal("", { cfg: { failOnMissingSnapshots: true } }).snap(),
MissingSnapshotError
)
})
})
6 changes: 3 additions & 3 deletions ark/attest/__tests__/benchExpectedOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ type makeComplexType<S extends string> =
: S

bench("bench type", () => ({}) as makeComplexType<"defenestration">).types([
177,
163,
"instantiations"
])

bench(
"bench type from external module",
() => ({}) as externalmakeComplexType<"defenestration">
).types([193, "instantiations"])
).types([179, "instantiations"])

bench(
"bench call and type",
() => ({}) as makeComplexType<"antidisestablishmentarianism">,
fakeCallOptions
)
.mean([2, "ms"])
.types([345, "instantiations"])
.types([317, "instantiations"])

bench("empty", () => {}).types([0, "instantiations"])
2 changes: 1 addition & 1 deletion ark/attest/__tests__/snapExpectedOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ attest({ [Symbol("mySymbol")]: 1 }).snap({ "Symbol(mySymbol)": 1 })
const it = (name: string, fn: () => void) => fn()

it("can snap instantiations", () => {
attest.instantiations([229, "instantiations"])
attest.instantiations([212, "instantiations"])
return {} as makeComplexType<"asbsdfsaodisfhsda">
})

Expand Down
7 changes: 6 additions & 1 deletion ark/attest/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export const runThenGetContents = (templatePath: string): string => {
const tempPath = templatePath + ".temp.ts"
copyFileSync(templatePath, tempPath)
try {
shell(`node --import=tsx ${tempPath}`, { cwd: dirName() })
shell(`node --import=tsx ${tempPath}`, {
cwd: dirName(),
env: {
ATTEST_failOnMissingSnapshots: "0"
}
})
} catch (e) {
console.error(e)
}
Expand Down
2 changes: 2 additions & 0 deletions ark/attest/assert/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const throwAssertionError = ({
throw e
}

export class MissingSnapshotError extends Error {}

export type AssertFn = (
expected: unknown,
actual: unknown,
Expand Down
21 changes: 11 additions & 10 deletions ark/attest/assert/chainableAssertions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { caller } from "@ark/fs"
import { caller, positionToString } from "@ark/fs"
import {
printable,
snapshot,
Expand All @@ -20,6 +20,7 @@ import type { Completions } from "../cache/writeAssertionCache.ts"
import { getConfig } from "../config.ts"
import { chainableNoOpProxy } from "../utils.ts"
import {
MissingSnapshotError,
TypeAssertionMapping,
assertEqualOrMatching,
assertEquals,
Expand Down Expand Up @@ -124,9 +125,15 @@ export class ChainableAssertions implements AssertionRecord {
const snapName = this.ctx.lastSnapName ?? "snap"
const expectedSerialized = snapshot(args[0])
if (!args.length || this.ctx.cfg.updateSnapshots) {
const position = caller()
if (this.ctx.cfg.failOnMissingSnapshots) {
throw new MissingSnapshotError(
`.${snapName}() at ${positionToString(position)} must be populated.`
)
}
if (this.snapRequiresUpdate(expectedSerialized)) {
const snapshotArgs: SnapshotArgs = {
position: caller(),
position,
serializedValue: this.serializedActual,
snapFunctionName: snapName
}
Expand Down Expand Up @@ -339,20 +346,14 @@ type snapProperty<expected, kind extends AssertionKind> = {
export type Unwrapper<expected = unknown> = (opts?: UnwrapOptions) => expected

export const nonOverlappingSatisfiesMessage =
"The type of your actual value and expected satisfies constraint have no overlap"
"This type has no overlap with your satisfies constraint"

export type nonOverlappingSatisfiesMessage =
typeof nonOverlappingSatisfiesMessage

type validateExpectedOverlaps<expected, satisfies> =
isDisjoint<expected, satisfies> extends true ?
ErrorType<
nonOverlappingSatisfiesMessage,
{
actual: expected
satisfies: satisfies
}
>
ErrorType<nonOverlappingSatisfiesMessage>
: unknown

export type comparableValueAssertion<expected, kind extends AssertionKind> = {
Expand Down
29 changes: 24 additions & 5 deletions ark/attest/cache/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,34 @@ export class TsServer {

getSourceFileOrThrow(path: string): ts.SourceFile {
const tsPath = path.replaceAll("\\", "/")
const file = this.virtualEnv.getSourceFile(tsPath)
if (!file) {
const existingFile = this.virtualEnv.getSourceFile(tsPath)
if (existingFile) return existingFile

if (!this.virtualEnv.sys.fileExists(tsPath)) {
throwInternalError(
`@ark/attest: TypeScript was unable to resolve expected file at ${tsPath}.\n`
)
}

const contents = this.virtualEnv.sys.readFile(tsPath)

if (!contents) {
throwInternalError(
`@ark/attest: TypeScript says a file exists at ${tsPath}, but was unable to read its contents.\n`
)
}

this.virtualEnv.createFile(tsPath, contents)

const createdFile = this.virtualEnv.getSourceFile(tsPath)

if (!createdFile) {
throwInternalError(
`TypeScript was unable to resolve expected file at ${path}.\n
Make sure it is included in your tsconfig.json.`
`@ark/attest: TypeScript tried to create a file at ${tsPath} but was unable to access it.`
)
}

return file
return createdFile
}
}

Expand Down
2 changes: 1 addition & 1 deletion ark/attest/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const baseFileName = basename(fileName())

const thisFileIndex = process.argv.findIndex(
// if running from build output in npm, will be a file called `attest`
// if running from build output in pnpm, will be cli.js in build output
// if running from build output in pnpm, will be `cli.js` in build output
s => s.endsWith(baseFileName) || s.endsWith("attest")
)

Expand Down
Loading