Fix permutations comment

This commit is contained in:
Michael B. Gale
2026-04-30 13:28:42 +01:00
parent 549683cee5
commit b77983290b
+11 -2
View File
@@ -61,8 +61,17 @@ export function withSchemaMatrix<S extends json.Schema>(
`value-for-${String(key)}`,
];
// Constructs an array of test objects, starting with `required` and adding
// acceptable values for any
// Constructs an array of test objects, starting with `required` and combining it with all
// possible states of each optional property. For example, with default settings:
//
// For { requiredKey: string }, we get: `[{ requiredKey: "some-string-value" }]`
//
// For { requiredKey: string, optionalKey?: string }, we get:
// [ { requiredKey: "some-string-value" },
// { requiredKey: "some-string-value", optionalKey: undefined },
// { requiredKey: "some-string-value", optionalKey: null },
// { requiredKey: "some-string-value", optionalKey: "some-value" },
// ]
const permutations = (keys: Array<keyof S>) => {
if (keys.length === 0) return [required];