Open
Description
Right now there is no way for consumers of this library to extend the metadata property in SharedFormProperties
because SharedFormProperties
isn't exported from the library.
Current Type Definition
// ./src/scheam.ts line 112
interface SharedFormProperties {
definitions?: { [definition: string]: Schema };
metadata?: { [name: string]: unknown };
nullable?: boolean;
}
Proposed Change
export interface SharedFormProperties {
definitions?: { [definition: string]: Schema };
metadata?: SchemaMetadata;
nullable?: boolean;
}
export interface SchemaMetadata {
[key: string]: unknown;
}
Reasoning
In doing this tools and apps that consume this library can define type hints for metadata that they use similar to how people extend the request object in Fastify or Express. (See an example here: fastify/help#122 (comment))
Here is an example of what this would allow. Writing a .d.ts
file like the following.
// jtd.d.ts
import "jtd"
declare module "jtd" {
export interface SchemaMetadata {
id?: string;
description?: string;
}
}
Metadata
Metadata
Assignees
Labels
No labels