This PR adds a Schema<Id> helper type as an export of @ethdebug/format. This provides all the schemas at the type-level (e.g., Schema<"schema:ethdebug/format/type"> equals { readonly $schema: string; readonly $id: string; /* ... */ }).
This sort of thing is necessary because TypeScript is not capable of inferring const types except for value literals... so this PR modifies the existing schema-to-module codegen process to stringify each schema as an object literal (in addition to the existing output of all the YAMLs as string literals). This new object dump is initialized with our friend as const.
Anyway, this sort of thing is a bit extraneous, but I figured it couldn't hurt. Having these raw schema const types is necessary for certain general-purpose solutions like json-schema-to-ts, although I was unable to get that package working with these schemas (it seems like a lot of people are having trouble with their recent releases).
In addition, this PR has a few other code improvements that have been polluting my draft pointer-schema branch, so I'm including them here.
This PR adds a
Schema<Id>
helper type as an export of @ethdebug/format. This provides all the schemas at the type-level (e.g.,Schema<"schema:ethdebug/format/type">
equals{ readonly $schema: string; readonly $id: string; /* ... */ }
).This sort of thing is necessary because TypeScript is not capable of inferring
const
types except for value literals... so this PR modifies the existing schema-to-module codegen process to stringify each schema as an object literal (in addition to the existing output of all the YAMLs as string literals). This new object dump is initialized with our friendas const
.Anyway, this sort of thing is a bit extraneous, but I figured it couldn't hurt. Having these raw schema const types is necessary for certain general-purpose solutions like json-schema-to-ts, although I was unable to get that package working with these schemas (it seems like a lot of people are having trouble with their recent releases).
In addition, this PR has a few other code improvements that have been polluting my draft
pointer-schema
branch, so I'm including them here.