diff --git a/lib/types/jtd-schema.ts b/lib/types/jtd-schema.ts index 0c76741b5..c5d70ef8b 100644 --- a/lib/types/jtd-schema.ts +++ b/lib/types/jtd-schema.ts @@ -206,6 +206,8 @@ type JTDDataDef> = : // type S extends {type: NumberType} ? number + : S extends {type: "boolean"} + ? boolean : S extends {type: "string"} ? string : S extends {type: "timestamp"} diff --git a/spec/types/jtd-schema.spec.ts b/spec/types/jtd-schema.spec.ts index e9c3d5d0f..eafb822e1 100644 --- a/spec/types/jtd-schema.spec.ts +++ b/spec/types/jtd-schema.spec.ts @@ -373,6 +373,13 @@ describe("JTDDataType", () => { void [num] }) + it("should typecheck boolean schemas", () => { + const booleanSchema = {type: "boolean"} as const + const bool: TypeEquality, boolean> = true + + void [bool] + }) + it("should typecheck string schemas", () => { const strSchema = {type: "string"} as const const str: TypeEquality, string> = true