Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ describe("Conversion from aqua to typescript", () => {
test.each`
aqua | ts | type
${1} | ${1} | ${i32}
${null} | ${null} | ${opt_i32}
${[]} | ${null} | ${opt_i32}
${[1]} | ${1} | ${opt_i32}
${[1, 2, 3]} | ${[1, 2, 3]} | ${array_i32}
Expand All @@ -205,7 +206,11 @@ describe("Conversion from aqua to typescript", () => {

// assert
expect(tsFromAqua).toStrictEqual(ts);
expect(aquaFromTs).toStrictEqual(aqua);

// 'null' -> 'null' -> [] ; 'null' not equal []
if (aqua !== null || ts !== null) {
expect(aquaFromTs).toStrictEqual(aqua);
}
},
);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/core/js-client/src/compilerSupport/conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export function aqua2js(
if (schema.tag === "nil") {
return null;
} else if (schema.tag === "option") {
if (!Array.isArray(value)) {
throw new SchemaValidationError(path, schema, "array", value);
if (!Array.isArray(value) && value !== null) {
throw new SchemaValidationError(path, schema, "array or null", value);
}

if ("0" in value) {
if (value !== null && "0" in value) {
return aqua2js(value[0], schema.type, { path: [...path, "?"] });
} else {
return null;
Expand Down