Skip to content

Commit fdd198b

Browse files
committed
test: assert runtime rejection of [] default for non-array bases
Add a matching .throws.snap(...) to the 'empty array default rejects non-array base' test so it verifies both the runtime parse error and the type-level error, consistent with the surrounding invalid-default tests (incorrect default type, non-literal, fails on expression value).
1 parent 87c90aa commit fdd198b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

ark/type/__tests__/objects/defaults.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,11 @@ contextualize(() => {
590590
it("empty array default rejects non-array base", () => {
591591
// [] is assignable only to array/tuple input types
592592
// @ts-expect-error
593-
attest(() => type({ foo: "number = []" })).type.errors(
594-
"Default value [] must be assignable to number"
595-
)
593+
attest(() => type({ foo: "number = []" }))
594+
.throws.snap(
595+
"ParseError: Default for foo must be a number (was an object)"
596+
)
597+
.type.errors("Default value [] must be assignable to number")
596598
})
597599
})
598600

0 commit comments

Comments
 (0)