Slide 13
Slide 13 text
const schema = {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: {
foo: { type: 'number' },
bar: { type: 'boolean' },
},
} as const satisfies JSONSchema7;
type T = FromSchema;
assertType<
T,
{
[x: string]: unknown;
foo?: number;
bar?: boolean;
}
>(true);
const schema = {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
additionalProperties: false,
properties: {
foo: { type: 'number' },
bar: { type: 'boolean' },
},
required: ['foo'],
} as const satisfies JSONSchema7;
type T = FromSchema;
assertType<
T,
{
foo: number;
bar?: boolean;
}
>(true);
w requiredadditionalProperties͕ࢦఆ͞Ε͍ͯͳ͍
w [x: string]: unknown;0QUJPOBMؚ͕·ΕΔ
w additionalProperties: falseͩͱ[x: string]:
unknownࢦఆؚ·Εͳ͍
w requiredʹج͍ͮͯ0QUJPOBM͕֎ΕΔ