Skip to content
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
2 changes: 1 addition & 1 deletion ambar-core/src/json/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,5 @@ const json: Decoder<Json> = rec((json) =>
oneOf([nullP, string, number, boolean, array(json), objectMap(json)])
);

const stringEnum = <T extends string[]>(strs: T): Decoder<T[number]> =>
const stringEnum = <const T extends string[]>(strs: T): Decoder<T[number]> =>
oneOf(strs.map(stringLiteral));
2 changes: 1 addition & 1 deletion ambar-core/src/json/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const oneOf = <V>(f: (v: V) => Encoder<V>): Encoder<V> =>
return encoder.run(input);
});

const stringEnum = <T extends string[]>(strs: T): Encoder<T[number]> =>
const stringEnum = <const T extends string[]>(strs: T): Encoder<T[number]> =>
string.rmap((input) => {
if (!strs.includes(input)) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion ambar-core/src/json/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const stringLiteral = <T extends string>(str: T): Schema<T> =>
})
);

const stringEnum = <T extends string[]>(strs: T): Schema<T[number]> =>
const stringEnum = <const T extends string[]>(strs: T): Schema<T[number]> =>
new Schema(D.stringEnum(strs), E.stringEnum(strs));

const oneOf = <V>(f: (v: V) => Schema<V>, ss: Array<Schema<V>>): Schema<V> =>
Expand Down